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

Detail DataGrid filtering with odata and/or json types

4 Answers 434 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Leo
Top achievements
Rank 1
Leo asked on 21 Dec 2011, 08:04 PM
I modified the “Detail Grid” which can be found here:


To use this example with a couple of Java actions instead of the RSS feed. However, I'm having problems filtering the detail data because of the fact that I’m omitting the type: "odata" in my HTML.



So, the original Employees data source looked like this:

dataSource: {
    type: "odata",
    transport: {
    },
    pageSize: 5,
    serverPaging: true,
    serverSorting: true
},



The original Orders data source looked like this:

dataSource: {
    type: "odata",
    transport: {
    },
    serverPaging: true,
    serverSorting: true,
    serverFiltering: true,
    pageSize:6,
    filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
},




The modified Employees data source looks like this:

dataSource: {
    transport: {
        read:  {
            url: "/site/GetEmployee.action",
            dataType: "json",
        },
    },
    pageSize: 5,
    serverPaging: true,
    serverSorting: true
},




The modified Orders data source looks like this:

dataSource: {
    transport: {
        read:  {
            url: "/site/GetOrders.action",
            dataType: "json",
        },
    },
    serverPaging: true,
    serverSorting: true,
    serverFiltering: true,
    pageSize:6,
    filter: { field: "EmployeeID", operator: "eq", value: e.data.EmployeeID }
},


You’ll notice that I had to make the change to: dataType: "json", in order for this example to work.

Also, if you look inside “kendo.all.js”, you’ll notice that “filter: { }” will only work with “odata”.

Now, any ideas how I can get my sample to work with filtering?

4 Answers, 1 is accepted

Sort by
0
Rich
Top achievements
Rank 1
answered on 28 Jan 2012, 04:22 PM
I am having the same issue using an ASP.NET MVC3 application. Has anyone found a solution to this issue?

Thanks!
0
Blop
Top achievements
Rank 1
answered on 18 Feb 2012, 02:45 PM
Hello,

   Filters only works with odata since filter is populated via kendo.data.odata.js .
   You will see on source file kendo.data.odata.js  that odata Datasource will map your filter request to an string value passed to service.
if (data.filter) {
     result.push("$filter=" + toOdataFilter(data.filter));
}

   It also add top, skip & order parameters. In addition, and due to odata specifications, it will add a callback() function to fullfill jsonp needs.

   I do not known how your services GetEmployee & GetOrder works.
Does they implements a OData service provider or a JSON/JSONP answer based on some parameters on url ?
Does they return a table like this :

{
"d":{
  results:{...},
  __count : 12345
 }
}

or does they return a direct table of objects ? :

[
 {id:"1",...},
 {id:"2",...}
]


I see 3 possibles solutions :
1. your services implements OData specification and you do not need to worry about json, use odata will feet your needs

2. your services implements a function returning a JSON table, and you have to use "data" to pass your parameters to your services and take care of filtering, sorting, top & skip
http://demos.kendoui.com/web/datasource/remote-data.html

3. advanced : Kendo OData format is only there to wrap filters, top, skip & sort  and returns a total & some results to bind on table (a subset of results). If your needs doesn't feet odata specification, you can do your own implementation based on kendo.data.odata.js

If you can post an example of what return your service & also witch parameters your services understand we could made a sample.

PoP
0
John
Top achievements
Rank 1
answered on 16 Jan 2014, 08:51 AM
how to create odata file,do u give any sample code
0
Daniel
Telerik team
answered on 21 Jan 2014, 09:10 AM
Hello,

The demo is using a WCF DataService. A sample project(grid-odata-crud) using a Grid with OData DataSource is available in our GitHub repository on this page.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Leo
Top achievements
Rank 1
Answers by
Rich
Top achievements
Rank 1
Blop
Top achievements
Rank 1
John
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or