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
985
How to pass metadata(column info) & data separately to grid datasource in json format
posted

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",

      "Sold-To":"10C1000",

      "Status":" ",

      "Line":1,

      "Item Number":"03021",

      "UM":"EA",

      "Qty Ordered":125,

      "Qty Open":125,

      "Due Date":"2012-01-25",

      "Qty Shipped":0,

      "Quote":" ",

      "Type":" ",

      "Purchase Order":" ",

      "Ship-To":"10C1000D",

      "Site":"10-300",

      "Customer Item":"WL500",

      "Description":" ",

      "Expires":null

   }

]

Parents
  • 24671
    Suggested Answer
    posted

    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

Reply Children