Binding XML to Grid - Error [object Object]

6 posts, 1 answers
  1. Philipp
    Philipp avatar
    8 posts
    Member since:
    Aug 2014

    Posted 25 Aug 2014 Link to this post

    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 ?
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2202 posts

    Posted 27 Aug 2014 Link to this post

    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.

     
  3. Philipp
    Philipp avatar
    8 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 in reply to Vladimir Iliev Link to this post

    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.
  4. Philipp
    Philipp avatar
    8 posts
    Member since:
    Aug 2014

    Posted 27 Aug 2014 in reply to Philipp Link to this post

    The Printscreen
  5. Answer
    Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2202 posts

    Posted 28 Aug 2014 Link to this post

    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.

     
  6. Philipp
    Philipp avatar
    8 posts
    Member since:
    Aug 2014

    Posted 01 Sep 2014 in reply to Vladimir Iliev Link to this post

    thanks a lot, it works now.
Back to Top