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

Filter Trouble

5 Answers 122 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Werit
Top achievements
Rank 1
Werit asked on 16 Jan 2012, 03:07 PM
This doesn't seem to return anything (Should show Jane), am I using Filters incorrectly?

var stuff = [
                  {
                      FirstName: "Joe",
                      LastName: "Smith"
                  },
                  {
                      FirstName: "Jane",
                      LastName: "Smith"
              }];
 
 var ds = new kendo.data.DataSource({data: stuff});   
 
$("#grid").kendoGrid({
          columns:[
              {
                  field: "FirstName",
                  title: "First Name"
              },
              {
                  field: "LastName",
                  title: "Last Name"
          }],
          dataSource: ds.filter([{ field: "FirstName", operator: "neq", value: "Joe" }])
 
});

5 Answers, 1 is accepted

Sort by
0
John DeVight
Top achievements
Rank 1
answered on 16 Jan 2012, 09:09 PM
Hi Werit,

The filter has some square brackets that shouldn't be there.  Also, I would move the call to the dataSource filter function to be defined before binding to the grid, and then the grid just binds to the dataSource:

var stuff = [
                  {
                      FirstName: "Joe",
                      LastName: "Smith"
                  },
                  {
                      FirstName: "Jane",
                      LastName: "Smith"
              }];
   
var ds = new kendo.data.DataSource({data: stuff});    
  
ds.filter({ field: "FirstName", operator: "neq", value: "Joe" });
  
$("#grid").kendoGrid({
          columns:[
              {
                  field: "FirstName",
                  title: "First Name"
              },
              {
                  field: "LastName",
                  title: "Last Name"
          }],
          dataSource: ds
});

Hope this helps....

Regards,

John DeVight
0
Werit
Top achievements
Rank 1
answered on 17 Jan 2012, 02:30 PM
Thanks,  I guess I was just thinking about filters wring.  Is it possible to do filtering at the UI level instead of the Datasource?
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 03:02 PM
Hi Werit,

Are you thinking of something like the Telerik Extensions for MVC Grid?  If so, I don't think that Kendo has anything like that yet.  You could periodically check the Readmap as well as post a request at: Kendo UI Feedback requesting the feature.  If you do post a request, let me know and I'll vote for it as well =)

Regards,

John DeVight
0
Atanas Korchev
Telerik team
answered on 17 Jan 2012, 05:19 PM
Hello,

 Grid filtering is already supported. Check this demo: http://demos.kendoui.com/web/grid/local-data.html 

Greetings,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
John DeVight
Top achievements
Rank 1
answered on 17 Jan 2012, 05:28 PM
LOL

Thanks Atanas.  No idea how I missed that! =)
Tags
Data Source
Asked by
Werit
Top achievements
Rank 1
Answers by
John DeVight
Top achievements
Rank 1
Werit
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or