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

Binding XML to Grid - Error [object Object]

5 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Philipp
Top achievements
Rank 1
Philipp asked on 25 Aug 2014, 08:37 AM
Hi

i'm using a Kendo UI Grid (Version: 2014.2.716.545) within a ASP .NET MVC 5 Project to bind XML Data from a local hosted Webservice. The following example works fine with IE 10, but not with Firefox, IE 11, etc.

<script type="text/javascript">
                $(document).ready(function () {
                    $("#systemLogs").kendoGrid({
                            dataSource: {
                                transport: {
                                    read: {
                                        url: 'http://localhost:9000/api/Home/GetSystemLogs")'
                                    },
                                dataType: "xml",
                            },
                            schema: {
                                model: {
                                    id: "LogId",
                                    fields: {
                                        Date: { type: "date" },
                                        Level: { type: "string" },
                                        Message: { type: "string" },
                                    }
                                }
                            },
                            pageSize: 10
                        },
                        height: 400,
                        sortable: false,
                        pageable: false,
                        columns: [
                            {
                                field: "Date",
                                title: "Date",
                                format: "{0:dd.MM.yyyy HH:mm}",
                                width: 150,
                            },
                            {
                                field: "Level",
                                title: "Level",
                                width: 50,
                            },
                            {
                                field: "Message",
                                title: "Message",
                                width: 300,
                            }
                        ]
                    });
                });
</script>

I always getting the Errormessage "[object Object]". What's wrong with my Javascript Code ?

5 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 27 Aug 2014, 08:12 AM
Hi Philipp,

From the provided information it seems that the grid schema is not correctly configured, however to be able to advice you further we would need runable example where the issue is reproduced (the server can return static data). This would help us pinpoint the exact reason for this behavior.

Kind Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Philipp
Top achievements
Rank 1
answered on 27 Aug 2014, 12:26 PM
Hi Vladimir

Thanks for your reply. The Server returns a XML with the following Schema:

<ArrayOfLogs>
  <Logs>
     <Checksum/>
     <Date>2014-08-26 15:59:44.9469</Date>
     <Level>Info</Level>
     <LogId>28</LogId>
     <Message>WebServer started on http://localhost:9000/ ...</Message>
     <State/>
   </Logs>
   <Logs>
      <Checksum/>
      <Date>2014-08-26 15:59:07.7965</Date>
      <Level>Info</Level>
      <LogId>26</LogId>
      <Message>Stop Import</Message>
      <State/>
    </Logs>.....

Please also look at the Printscreen.
0
Philipp
Top achievements
Rank 1
answered on 27 Aug 2014, 12:27 PM
The Printscreen
0
Accepted
Vladimir Iliev
Telerik team
answered on 29 Aug 2014, 04:37 AM
Hi,

You can check the example dataSource "schema" configuration based on the provided XML schema:

$("#grid").kendoGrid({
    dataSource:  new kendo.data.DataSource({
        transport: {
            // specify the XML file to read. The same as read: { url: "logs.xml" }
            read: "logs.xml"
        },
        schema: {
            // specify the the schema is XML
            type: "xml",
            // the XML element which represents a single data record
            data: "/ArrayOfLogs/Logs",
            // define the model - the object which will represent a single data record
            model: {
                // set the model ID field
                id: "LogId",
                // configure the fields of the object
                fields: {
                    // the "Message" field is mapped to the text of the "Message" XML element
                    Message: "Message/text()",
                    // the "LogId" field is mapped to the text of the "LogId" XML element
                    LogId: "LogId/text()",
                    // the "Date" field is mapped to the text of the "Date" XML element
                    Date: "Date/text()",
                    // the "Checksum" field is mapped to the text of the "Checksum" XML element
                    Checksum: "Checksum/text()",
                    // the "State" field is mapped to the text of the "State" XML element
                    State: "State/text()"
                }
            }
        }
    }),
    scrollable: false,
    sortable: true
});

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Philipp
Top achievements
Rank 1
answered on 01 Sep 2014, 07:19 AM
thanks a lot, it works now.
Tags
Grid
Asked by
Philipp
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Philipp
Top achievements
Rank 1
Share this question
or