This is a migrated thread and some comments may be shown as answers.

Creating a Custom Grid Column and fill data

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mr.
Top achievements
Rank 1
Mr. asked on 25 May 2016, 01:28 PM

I have received the data in json format as follows:

var mydata = [
{
"Title":"My Grid Example",
"NumberOfColumns":4,
"DatasetHeader":{"items":[
{"Name":"FullName","Type":"System.String"},
{"Name":"Age","Type":"System.Int32"},
"Name":"Address","Type":"System.String"},
{"Name":"Cost","Type":"System.Double"}
]},
"Rows":["items":[
{"Rohan","12","Arab","234"},
{"Radha","11","Texas","123"},
{"Haris","22","NPL","344"},
{"Christine","23","Arab","674"},
{"Tot","22","UK","434"},
{"Terry","21","LA","334"},
{"Savana","19","SA","224"}
]}
}];

Now, I want to generate the dynamic grid with the above data with 4 columns and 7 rows (for this case) . The columns can varies during runtime (from 2-3 to 14-15)

Something like this is expected:

<script>

$(document).ready(function () {

generateGrid(mydata);

}

function generateGrid(receiveddata) {

$("#table-grid").kendoGrid({

dataSource: { data: receiveddata.Rows.Items},

height: 400,
scrollable: true,

schema: {
        model: receiveddata.DatasetHeader.items
      },

title: receiveddata.title

});

} //end of javascript function

</script>

<div id="table-grid"></div>

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 30 May 2016, 10:42 AM
Hello,

From what I could see, the items collection in the Rows does not contain valid JSON structure, so it will not be possible to use that data in the Grid. You could however parse it to a valid data before passing it to the dataSource and the model of the widget:
Additionally, for all sides convenience, please use the correct product section when you open new threads. Thank you for your understanding.


Best Regards,
Konstantin Dikov
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Mr.
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or