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

Muti Check filter default value?

5 Answers 432 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vince
Top achievements
Rank 1
Vince asked on 12 Jan 2017, 04:01 PM

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?

5 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 16 Jan 2017, 08:57 AM
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.
0
Vince
Top achievements
Rank 1
answered on 17 Jan 2017, 06:25 PM

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.

0
Vince
Top achievements
Rank 1
answered on 18 Jan 2017, 09:52 PM
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. 
0
Konstantin Dikov
Telerik team
answered on 19 Jan 2017, 12:06 PM
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.
0
Vince
Top achievements
Rank 1
answered on 19 Jan 2017, 03:55 PM

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

 

Thanks so much! It works perfect!

Tags
Grid
Asked by
Vince
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Vince
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or