Muti Check filter default value?

6 posts, 0 answers
  1. Vince
    Vince avatar
    13 posts
    Member since:
    Dec 2016

    Posted 12 Jan 2017 Link to this post

    Hi,

    I'm trying to use a mult-checkbox filter like the demo on https://demos.telerik.com/aspnet-mvc/grid/filter-multi-checkboxes.

    columns.Bound(c => c.status).Title("Status").Filterable(ftb => ftb.Multi(true)); And it's client side[.ServerOperation(false)].

    Currently I have "act" and "inact" value in this column. I want to show only the "act" records when the page is loaded. Is that possible to give a default or pre-checked value to the muti-checkbox?

  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1502 posts

    Posted 16 Jan 2017 Link to this post

    Hello Vince,

    You can use the filter method in order to filter the grid. For example you can execute the following code in the browser console of the Grid / Filter Multi Checkboxes demo to filter the client grid by the Discontinued column with true value:
    $("#client").data("kendoGrid").dataSource.filter({ logic: "and", filters: [{field: "Discontinued", operator: "eq", value: true }] })

    Regards,
    Danail Vasilev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Vince
    Vince avatar
    13 posts
    Member since:
    Dec 2016

    Posted 17 Jan 2017 in reply to Danail Vasilev Link to this post

    Thank for your reply. I'm sorry that I didnt get your point. 

    In the Grid / Filter Multi Checkboxes demo, can I make the checkbox  "True" under the Discontinued filter  CHECKED BY DEFAULT while the grid is loaded?  I tried your code, nothing happens.

  4. Vince
    Vince avatar
    13 posts
    Member since:
    Dec 2016

    Posted 18 Jan 2017 in reply to Vince Link to this post

    I think I understand what you mean. Your solution is that add a filter manually before the page load, right? However, I got "Cannot read property 'dataSource' of null" error. 
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 19 Jan 2017 Link to this post

    Hi Vince,

    You need to ensure that you are trying to get reference to the grid with the correct ID and after its initialization (within document ready).

    Another thing that you can try is to set the initial filter directly in the DataSource of the Grid:
    .DataSource(dataSource => dataSource       
        .Ajax()      
        .Filter(f=>f.Add(x=>x.Discontinued).IsEqualTo(true))

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  6. Vince
    Vince avatar
    13 posts
    Member since:
    Dec 2016

    Posted 19 Jan 2017 in reply to Konstantin Dikov Link to this post

    .DataSource(dataSource => dataSource       
        .Ajax()      
        .Filter(f=>f.Add(x=>x.Discontinued).IsEqualTo(true))

     

    Thanks so much! It works perfect!

Back to Top