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

DataSource Filtering

2 Answers 363 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 2
Markus asked on 16 Apr 2013, 07:28 AM
I am absolutely new to Kenod and all it attached features and needed tasks - so please forgive me.

I was able to retrieve data from my sql database and bind it to a tabstrip.

var dsBuecherAT = new kendo.data.DataSource(
                    {
                    transport: {
                            read: {
                            url: "/api/t_buechers",
                            dataType: "json"
                        }
                        }
                });
                 
                $("#buecherAT").kendoTabStrip({
                    dataTextField: "Buch",
                    dataContentField: "Buch_ID",
                    dataSource: dsBuecherAT
                });
However when I try to filter (remember I am actually clueless what I am doing) its not working.

1)  http://docs.kendoui.com/api/framework/datasource the syntax looks like

var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe" },
    { name: "John Doe" }
  ],
  filter: { field: "name", operator: "startswith", value: "Jane" }
});
If I search the web I mostly find fiields operator and value in""

Does it matter?
Which is correct?

var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe" },
    { name: "John Doe" }
  ],
  filter: { "field": "name", "operator:" "startswith", "value:" "Jane" }
});

2) this are two ways I tried and both did not work. Any suggestions?

Try # 1

//we are getting the kapitels
               function getKapitels(buch_ID) {
                   alert(buch_ID);
                   var dsKapitels = new kendo.data.DataSource({
                       transport: {
                           read: {
                               url: "/api/t_kapitels",
                               dataType: "json"
                           }
                       }
 
                   });
 
                   $("#kapitel").kendoTabStrip({
                
                       dataTextField: "Kapitel_ID",
                       dataContentField: "Buch_ID",
                       dataSource: dsKapitels.filter({ field: "Buch_ID", operator: "eq", value: "1" })
                   })
               }
Try #2

 
//we are getting the kapitels
               function getKapitels(buch_ID) {
                   alert(buch_ID);
                   var dsKapitels = new kendo.data.DataSource({
                       transport: {
                           read: {
                               url: "/api/t_kapitels",
                               dataType: "json"
                           }
                       },
                         
                      filter: { field: "Buch_ID", operator: "eq", value: "1" }
 
                   });
 
                   $("#kapitel").kendoTabStrip({
                
                       dataTextField: "Kapitel_ID",
                       dataContentField: "Buch_ID",
                       dataSource: dsKapitels
                   })
               }

Any help is appreciated, and please forgive me if these questions are to clear.

Markus

2 Answers, 1 is accepted

Sort by
0
Holger
Top achievements
Rank 1
answered on 16 Apr 2013, 11:14 AM
Hi Markus,

generally both ways of defining a filter will work fine. Please have a look at the following JS Bin: http://jsbin.com/uketom/3/edit

In your second sample there are some errors, Look at this JS Bin to see the warnings: http://jsbin.com/agokib/1/edit

Regards,
Holger
0
Markus
Top achievements
Rank 2
answered on 16 Apr 2013, 02:39 PM
Dear Holger

Thank's a lot. I will take a look at them.

Markus
Tags
General Discussions
Asked by
Markus
Top achievements
Rank 2
Answers by
Holger
Top achievements
Rank 1
Markus
Top achievements
Rank 2
Share this question
or