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

Datasource filter - get Value from XML node

1 Answer 226 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 27 Feb 2012, 04:30 PM
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" ]
    });
}

1 Answer, 1 is accepted

Sort by
0
Jason
Top achievements
Rank 1
answered on 25 Oct 2012, 02:49 PM
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,  
Tags
Data Source
Asked by
Lee
Top achievements
Rank 1
Answers by
Jason
Top achievements
Rank 1
Share this question
or