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

How to filter MVC Telerik Grid Checkbox like checked/nonchecked

10 Answers 192 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saul
Top achievements
Rank 1
Saul asked on 13 Feb 2014, 09:45 AM
I am using mvc telerik grid on my project and i have checbox inside this gridI just want to filter my checkbox like check or non checked in filter boxIs it possible?Is there any experience for this situation to help me?

     @( Html.Telerik().Grid<Orpac.Models.Time>()
                   .Name("timecmb")
                   .NoRecordsTemplate("No users to display")
                   .DataKeys(keys => keys.Add(k => k.Ident))
                   .DataBinding(d => d.Ajax().Select("GridTimeBinding", "Rule"))
                   .Columns(c =>{c.Bound(e => e.Ident).Width(90).ClientTemplate("<input type='checkbox' id='123' value='<#= Code #>'   <#=bit? checked='checked' : '' #> />").Title((string)ViewData["Select"]);c.Bound(e=>e.Code).Width(150).Title((string)ViewData["TimeCode"]);c.Bound(e=>e.Desc).Width(300).Title((string)ViewData["Description"]); })        
                   .ClientEvents(events => events.OnRowDataBound("onrowDataBoundtimepopup").OnDataBound("onDataBoundTimeRule"))
                  .Selectable()
                  .Footer(true)
                  .Sortable()
                  .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
                  .Scrollable(scrolling => scrolling.Height(190))
                  .Pageable(p=>p.PageSize(10))
)
 
This is the example of my gridThnx

10 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 14 Feb 2014, 03:39 PM
Hi Saul,


In general the filter menu is used to filter dataSource items, not Grid rows. Are referring to just filtering the rows, depending on whether the checkboxes are clicked or not? Or the checkboxes are used to modify the values in the dataSource?

Please elaborate a bit more on what exactly is the desired behavior, so I could assist further. As a side note, I would like to remind you that the Telerik MVC Extensions have been discontinued after a long maintenance phase, which was announced in mid-2012. Their support was discontinued too.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Saul
Top achievements
Rank 1
answered on 15 Feb 2014, 06:54 PM
Hi Dimiter

Actually i just filtering the rows, depending on whether the checkboxes are clicked or not

If i cant do this? How Can i put the checked values on top inside grid? like checked rows on top and non checked checkbox under that.

Thanks
0
Dimiter Madjarov
Telerik team
answered on 18 Feb 2014, 11:01 AM
Hello Saul,


The column could be filtered only if it is bound to some model property. I assume that just sorting the column would also work in the current case as you mentioned putting the checked rows on top. For your convenience I prepared a modified version of the following Code Library, which demonstrates similar scenario (it is using the Kendo UI Grid). You could find it attached to my post.


Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Saul
Top achievements
Rank 1
answered on 18 Feb 2014, 02:40 PM
Yes Dimitar 

This is what i want.

But i'm working on Telerik Grid and i'm getting row id from that checkbox when the checkbox checked.

If i convert this ,is it effect my situation?

Thnx 



0
Dimiter Madjarov
Telerik team
answered on 20 Feb 2014, 09:28 AM
Hello Saul,


Yes, the main functionality of the Code Library could be converted to work with the Telerik Grid. Some changes should be applied, as some of the used methods are not existing in the MVC Extensions. For example you should use the updateRow method of the Telerik Grid instead of the set method of the Observable object in Kendo UI.

I wish you a great day!

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dongfen
Top achievements
Rank 1
answered on 30 Jul 2014, 03:15 PM
Hi, Dimiter,

I used you example, and it worked fine.  Thanks.
But I have a different situation.  My grid's data source is a set of pre-determined terms.
When user comes to this page, it is always those items in the grid.  User can click Check All checkbox to check all check boxes and then save whatever they selected.  Great, works fine just like your example.
But I have a scenario that when user first come to the page, I want all the check box checked, user can un-check or re-check, no problem.  

The problem is that when all items are default to checked, user click save right away, nothing happens because grid is not dirty, cannot be saved.    

Any idea how I can get this done?

Thanks.

Dongfen
0
Dimiter Madjarov
Telerik team
answered on 31 Jul 2014, 11:30 AM
Hello Dongfen,


I assume that the approach from the Code Library will work in the current case too and more specifically the implementation in the checkAll function.

Let me know if this was the information that you were looking for or I could assist further.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dongfen
Top achievements
Rank 1
answered on 31 Jul 2014, 06:48 PM
Yes.  That is example I am using.
But for one of my scenarios, I need to set default to check all when user first get to it.
I want user to click save so that I will save these selected values.  But when default is set to select all, the grid seem not changed, it go by-pass ajax update routine.
0
Dimiter Madjarov
Telerik team
answered on 01 Aug 2014, 10:48 AM
Hello Dongfen,


Triggering the click event of the master checkbox in the first dataBound event of the Grid works as expected - the items are set as dirty. A sample implementation would be to set the AutoBind option of the Grid and manually trigger the read of the items.
E.g.
Html.Kendo().Grid<...>()
        .Name("grid")
        .AutoBind(false)
$(function () {
    var grid = $("#grid").data("kendoGrid");
    grid.one("dataBound", function () {
        $("#masterCheckBox").click();
    });
    grid.dataSource.read();
});

I hope this information helps.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dongfen
Top achievements
Rank 1
answered on 04 Aug 2014, 03:55 PM
Thank you, Dimiter.

That setting AutoBind as false has solved my problem.

Dongfen
Tags
Grid
Asked by
Saul
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Saul
Top achievements
Rank 1
Dongfen
Top achievements
Rank 1
Share this question
or