Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
420
Cannot Get The Grid To Work....
posted

"Uncaught Error: There was an error parsing the JSON data and applying the defined data schema: The input data doesn't match the schema, the following field couldn't be mapped: MyKeyGuid"

I receive this error no matter what I do/set....what can I do here? 

My Data:

{"Table":[{"MyKeyGuid":"9eb191d8-14bf-4159-b8a6-5da004afbc15","Name":"TestTitle","Agent":"TestData"}],"Table1":[{"OwnerGuid":"9eb191d8-14bf-4159-b8a6-5da004afbc15","Trxid":43182,"TrxDate":"2005-11-01T00:00:00","Rent":383.9874,"Suspended":false},{"MyKeyGuid":"9eb191d8-14bf-4159-b8a6-5da004afbc15","Trxid":71455,"TrxDate":"2017-05-01T00:00:00","Base":420.0240,"Suspended":false}]}

My Code (I have quite a bit commented out just to try and make this work.)

$("#myGrid").igHierarchicalGrid({

key: "Table",
width: "100%",
dataSource: data,
dataSourceType: "json",
//responseDataKey: "results",
autoGenerateColumns: false,
autofitLastColumn: false,
primaryKey: "MyKeyGuid",
columns: [
{ key: "MyKeyGuid", headerText: "KeyGuid", dataType: "string", width: "20%" },
{ key: "Name", headerText: "First Name", dataType: "string", width: "20%" },
{ key: "Agent", headerText: "Title", dataType: "string", width: "20%" }
],
autoGenerateLayouts: false,
columnLayouts: [
 {
 key: "Table1",
 autoGenerateColumns: false,
 autofitLastColumn: false,
 primaryKey: "MyKeyGuid",
 width: "100%",
 dataSource: data,
columns: [
{ key: "Trxid", headerText: "Trx", dataType: "number", width: "0%", hidden: true },
 { key: "MyKeyGuid", headerText: "MyKey", dataType: "string", width: "20%" },
 { key: "TrxDate", headerText: "TrxDate", dataType: "string", width: "20%" },
 { key: "Rent", headerText: "Rent", dataType: "string", width: "20%" },
 { key: "Suspended", headerText: "Suspended", dataType: "string", width: "0%", hidden: true }
 ]

});

Parents
No Data
Reply
  • 200
    Offline posted

    Hello William,

    What I observed in the provided snippet is that the data source is not in the correct format. I modified the data to a valid format as following:

    var data1 = {
                   "Table": [{
                                  "MyKeyGuid": "9eb191d8-14bf-4159-b8a6-5da004afbc15",
                                  "Name": "TestTitle",
                                  "Agent": "TestData",
                                  "Table1": [{
                                                 "OwnerGuid": "9eb191d8-14bf-4159-b8a6-5da004afbc15",
                                                 "Trxid": 43182,
                                                 "TrxDate": "2005-11-01T00:00:00",
                                                 "Rent": 383.9874,
                                                 "Suspended": false
                                  },
                                  {
                                                 "MyKeyGuid": "9eb191d8-14bf-4159-b8a6-5da004afbc15",
                                                 "Trxid": 71455,
                                                 "TrxDate": "2017-05-01T00:00:00",
                                                 "Base": 420.0240,
                                                 "Suspended": false
                                  }]
                   }],
    };

    Additionally, I noticed that the values in “MyKeyGuid” column, which is set as primaryKey, are not unique. By design, igHierarachicalGrid uses the primaryKey to uniquely distinguish records, which means that all values should be unique. Having this in mind, I changed the primaryKey to “Trxid” column.

    Attached you can find a sample with the modified data source which works as expected. Please test it and let me know whether it behaves as expected on your side.

    In case this is not an accurate representation of what you are trying to achieve feel free to get back to me with more details regarding your requirement.

    hgridSample.zip

Children