DataSource Filtering

3 posts, 0 answers
  1. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 16 Apr 2013 Link to this post

    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. Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 16 Apr 2013 Link to this post

    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
  3. Kendo UI is VS 2017 Ready
  4. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 16 Apr 2013 Link to this post

    Dear Holger

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

    Markus
Back to Top