I would like to pass column-info & data separately to datasource in json form. having column header label in each row is very expensive for large data set. also it's duplication of data, is there any way, we can specify it in json format output and pass it to grid datasource?
here is a example of json output:
[
{
"Order":"10S10010",
"Sold-To":"10C1000",
"Status":" ",
"Line":1,
"Item Number":"60007",
"UM":"EA",
"Qty Ordered":10,
"Qty Open":10,
"Due Date":"2011-10-14",
"Qty Shipped":0,
"Quote":" ",
"Type":" ",
"Purchase Order":" ",
"Ship-To":"10C1000",
"Site":"10-100",
"Customer Item":" ",
"Description":" ",
"Expires":null
},
- - -
"Order":"SO011203",
"Item Number":"03021",
"Qty Ordered":125,
"Qty Open":125,
"Due Date":"2012-01-25",
"Ship-To":"10C1000D",
"Site":"10-300",
"Customer Item":"WL500",
}
]
Hi,
I am not sure i understand the question. Basically every column header has headerText, which you can specify either manually, or automatically - in that case the column (property) key becomes the header text. there is no extra data stored for every row.
Would you like to pass extra data and associate it with every column header? In that case you can use jQuery's data() API, and associate this extra meta-data with every column header. Even though i don't think it's necessary to encode that in the DOM, provided that based on the columnKey, or columnIndex, you can always retrieve this extra metadata directly from your data structure. Your data structure may be something like this:
var dataSource = {
"Records": [
// array of records
{ ... }, {... }
],
"ColumnMetadata": { < array of objects describing the columns metadata > }
then when you pass this to the grid, you only need to specify the responseDataKey: "Records" so that the grid knows it's not binding to the list of records directly ,but needs to evaluate the Records proprety in the JSON. other than that you can always refer to the dataSource.ColumnMetadata from anywhere in your app.
Let me know if this helps. Thanks,
Angel
Hi Angel, Thanks for answer, I have tried your solution, it did worked except one issue, column headers are not correct, looks like I don't know ColumnMetadata format, can you please let me know.
Also if possible what other info can be added to meta data? like column-width, hidden columns etc..
Code Sample:
datasource = "">vmrfj03.qad.com:16560/.../jsonBrowse.jsp
Json Output:
{"ColumnMetadata":[["Customer","Sort Name","Telephone","City","State","Postal Code","Region","Country","Bill To","Type","County","Added","Site","Currency"]],
"BrowseData":[["10-100","QMI - USA Division"," ","East Hanover","NJ","07950","US-E","USA - TAX PURPOSE"," ","INTC"," ",null,"10-100","USD"],["10-300","QMI - USA Division"," ","East Hanover","NJ","07950","US-E","USA - TAX PURPOSE"," ","INTC"," ",null,"10-300","USD"]]}