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",
}
]
Thanks Angel, I ended up doing something like this:
1. Set autoGenerateColumns: false
2. AJAX Webservice Call to get column shema in json format
columns: jsonColumnSchema.Visible,
3. AJAX Webservice Call to get grid data in json format ( just values not column-names), I can't use datasource as webservice url, as it was generating columns twice in the same grid even if autoGenerateColumns set to false.
dataSource: jsonBrowseData.BrowseData,
Sample Column Shema json:
Sample Grid Data json:
] }
Hi,
there is no special format for this - i just suggested a name which you can use to send your own custom format, that you are going to interpret on the client side.
Regarding hiding, widths, etc. this is already encoded in the column settings for the features, there is no need for special column metadata. if you want to change a column width:
columns: [
{ key: 'somekey', headerText: 'text', width: '400px' }
if you'd like to make a column hidden, add a hidden: true to the colum definition. If you'd like to allow a column to participate in hiding / resizing, etc.:
features: [
name: 'Resizing',
columnSettings: [
{ columnKey: 'somekey', allowResizing :false }
Hope it 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"]]}
Hello annasaheb,
Follow the approach suggested by Angel and let me know if you need further assistance.
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,