Datasource filter - get Value from XML node

2 posts, 0 answers
  1. Lee
    Lee avatar
    46 posts
    Member since:
    Feb 2012

    Posted 27 Feb 2012 Link to this post

    Using the example set out in the following page: 

    http://demos.kendoui.com/web/grid/hierarchy.html

    I have tried to get this to use XML as the datasource instead of oData.  I get an "d is not defined" javascript error.

    I think it must be the filter that is not working.

    filter: { field: "customer", operator: "eq", value: "id/text()" } 


    but I cannot find any examples of the Grid using XML, and do not know what to put for the "value" to get this to match up to the value of the "id" node in the customers XML file - can anyone help?   The whole code is below.

    $(document).ready(function() {
        var element = $("#grid").kendoGrid({
     
             
           dataSource: new kendo.data.DataSource({
               type: "xml", // specifies data protocol
               pageSize: 6, // limits result set
               serverPaging: true,
               serverSorting: true,                       
               transport: {
                read: "customers.xml"
               },
                schema: {
                    type: "xml",
                    data: "/Customers/Customer",
                    model: {
                        fields: {
                            id: "id/text()",
                            surname: "surname/text()",
                            forename: "forename/text()",
                            email: "email/text()"
                        }
                    }
                }   
              }),
            height: 450,
            sortable: true,
            pageable: true,
            detailInit: detailInit,
            dataBound: function() {
                this.expandRow(this.tbody.find("tr.k-master-row").first());
            },
            columns: [{
                    field:"id",
                    filterable: false
                },
                "surname",
                "forename",
                "email"
            ]
        });
    });
     
    function detailInit(e) {
        $("<div/>").appendTo(e.detailCell).kendoGrid({
            dataSource: {
                type: "xml",
                transport: {
                    read: "orders.xml"
                },
                schema: {
                    type: "xml",
                    data: "/orders/order",
                    model: {
                        fields: {
                            id: "id/text()",
                            net: "net/text()",
                            vat: "vat/text()",
                            dispatched: "dispatched/text()"
                        }
                    }
                },  
                                     
                serverPaging: true,
                serverSorting: true,
                serverFiltering: true,
                pageSize:6,
                filter: { field: "customer", operator: "eq", value: "id/text()" }
            },
            scrollable: false,
            sortable: true,
            pageable: true,
            columns: [ "id", "net", "vat", "dispatched" ]
        });
    }
  2. Jason
    Jason avatar
    1 posts
    Member since:
    Oct 2012

    Posted 25 Oct 2012 Link to this post

    I have been fighting the same thing, and when I looked at your code I tried something and it worked right away. I was using JSON and thought it was a need for odata but its actually a setting.
    RemoveserverFiltering: true,  
Back to Top