Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
I'm trying to set dataSource to a variable containing xml information but the Kendo Grid show with any data.

My variable returnValue value is;

"<?xml version="1.0" encoding="UTF-8"?>
<logData>
<log><historyId>12</historyId><userId>1</userId><taskDate>2013-08-12 00:00:00</taskDate></log>
<log><historyId>13</historyId><userId>1</userId><taskDate>2013-08-14 00:00:00</taskDate></log>
<log><historyId>14</historyId><userId>1</userId><taskDate>2013-08-15 00:00:00</taskDate></log>
<log><historyId>15</historyId><userId>1</userId><taskDate>2013-08-19 00:00:00</taskDate></log>
<log><historyId>16</historyId><userId>1</userId><taskDate>2013-08-21 00:00:00</taskDate></log>
</logData>"
My html code is;

$("#grid").kendoGrid({
                dataSource: {
                    data: returnValue,
                    schema: {
                        model: {
                            fields: {
                                historyId: { type: "number" },
                                userId: { type: "number" },
                                taskDate: { type: "string" }
                            }
                        }
                    },
                    pageSize: 20
                },
                height: 550,
                scrollable: true,
                sortable: true,
                filterable: true,
                pageable: {
                    input: true,
                    numeric: false
                },
                columns: [
                    { field: "historyId", title: "History ID", format: "{0:c}", width: "130px" },
                    { field: "userId", title: "User ID", format: "{0:c}", width: "130px" },
                    { field: "taskDate", title: "Task Date", width: "130px" }
                ]
            });
Posted

1 solution

According to Telerik, you have to define the type and root of xml...
JavaScript
schema: {
  type: 'xml',
  data: '/logData/log',
  model: {
    fields: {
      historyId: 'historyId/text()',
      userId: 'userId/text()',
      taskDate: 'taskDate/text()
    }
  }
},

Remove also the <?xml version="1.0" encoding="UTF-8"?> part from the string...
 
Share this answer
 
v2
Comments
Archie Bou 20-Oct-14 12:57pm    
Before the changes the page show the grid with column headers and paging area. After the changes the page show only a gray square.
Kornfeld Eliyahu Peter 20-Oct-14 13:07pm    
I didn't checked you field declarations...it should be a bit different in case of XML source...see updated answer...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900