Grid Column Filter for number type

4 posts, 0 answers
  1. Anna
    Anna avatar
    64 posts
    Member since:
    Jul 2015

    Posted 03 Jun 2016 Link to this post

    Hi,

    I have problem to get filter on number type column working. Plunk: http://plnkr.co/edit/sBaDyB9OZtAJ9BKjQzwK?p=preview, The data structure as follow

    Sample data: 

    [{
        account: "AC",
        portfolio: "B",
        spendLine: [210, 220, 230, 240, 250]
      },
      ...
    ]

    Since the data structure has array within array, I have trouble defining schema model. The column filter for the number type is always using string filter instead of number. How can I solve this problem?

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 07 Jun 2016 Link to this post

    Hello Ama,

    The Kendo UI DataSource is designed to operate with flat data which is why there is no specified type for 'object' or 'array'.Since such types are not officially supported there is no built-in filtering menus for such cases.

    However the Filter Array Columns Using MultiSelect how-to shows how to enable filtering on a Grid column which is bound to an array field by using the Kendo UI Multiselect widget.

    Regards,
    Boyan Dimitrov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Anna
    Anna avatar
    64 posts
    Member since:
    Jul 2015

    Posted 07 Jun 2016 in reply to Boyan Dimitrov Link to this post

    That's a shame. Is there not a way to do number filtering in this case at all? Like I know we can customize the UI, is there opportunity to customize the operators?

    Best,

    Ama

  4. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    2062 posts

    Posted 09 Jun 2016 Link to this post

    Hello Ama,

    As I mentioned the Kendo UI DataSource is designed to work with flat data. Since there is no option to define a type of  'object' or 'array' there is no built-in filter mechanism for such data types. 

    There is a built-in number filtering, but it expects the cell to contain a single number value, not an array. The data structure should look like this in order to use the built-in number filtering: 

    [{
        account: "AC",
        portfolio: "B",
        spendLine: 210
      },
      ...
    ]


    Regarding the operator - the logic for the operator should be defined as separate function. For testing purposes in the provided how-to there is only one operator. It checks whether any of the values selected by the Kendo UI MultiSelect matches one of the numbers in the cell. 

    Since such data type is not supported by the Kendo UI DataSource there is no built-in filter operators for working with an array of numbers. Such operators should be implemented by the developer in the same way as the one used in the example. 

    In order to have more than one operator you can define Kendo UI DropDownList list and pass the selected operator to the Kendo Ui DataSource filter method.  

    Regards,
    Boyan Dimitrov
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
Back to Top