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

Telerik MVC Grid (NOT KENDO) - How to toggle all check boxes?

3 Answers 116 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Fabio
Top achievements
Rank 1
Fabio asked on 09 Sep 2014, 10:50 PM
How do I turn on/off all check boxes in a Telerik Grid?

I have a grid with 3 columns (Name, IsActive, IsDefault) -
The IsActive and IsDefault rows have a check box in them.

My Header column for both IsActive and IsDefault have a HeaderTemplate with a check box.
I want to be able to check/uncheck the header check box and have that chance propagate to all check boxes below.

I am also using batch edit - So I'll check batch edit first, check/uncheck all and click save

Screen shot: http://tinypic.com/r/27zxo39/8

3 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 12 Sep 2014, 03:49 PM
Hello Fabio,

This could be achieved by subscribing to the click event of the checkbox in the header and once it is triggered - iterate over the Grid's rows, pass them to the dataItem method and modify the values accordingly.
Also please note that as of June 2013, Telerik Extensions for ASP.NET MVC has reached its official End of Life, with no additional fixes or enhancements expected in the future. I would strongly recommend to upgrade to Telerik UI for ASP.NET MVC as we no longer provide support for the Telerik Extensions.

Regards,
Alexander Popov
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
Fabio
Top achievements
Rank 1
answered on 12 Sep 2014, 05:42 PM
Our product has been out for 4 years and it is deeply embedded with Telerik controls.  We have so much logic in the client controls that unfortunately upgrading to Kendo UI is not feasible at the moment.   I wish I could run it side by side with Telerik, but there seems to be a problem with the Jquery version, but anyways.

Thank you for the reply.  I have one more question to you.
I am trying to get a hold of all rows but when I call "grid.data" I always get null - Can you tell me what is wrong?

Here is the sample code:

01.@using Telerik.Web.Mvc.UI
02.@model List<TelerikTest.Controllers.Foo>
03. 
04.@(Html.Telerik().Grid(Model)
05.      .Name("FooGrid")
06.      .TableHtmlAttributes(new {@style = "width:500px;"})
07.      .HtmlAttributes(new {@style = "width:500px;"})
08.      .DataBinding(builder => builder.Server())
09..Columns(c =>
10.    {
11.        c.Bound(model => model.Name);
12.        c.Bound(model => model.IsActive).HeaderTemplate("<input type=\"checkbox\" name=\"IsActiveHeader\" checked onchange=\"ToggleActiveChkBoxes(this)\"/><div>Active</div>");
13.        c.Bound(model => model.IsDefault).HeaderTemplate("<input type=\"checkbox\" name=\"IsActiveHeader\" checked onchange=\"ToggleDefaultChkBoxes(this)\"/><div>Default</div>");
14.    }))
15. 
16.<script type="text/javascript">
17.     
18.    function ToggleActiveChkBoxes(e) {
19.        //Get the grid data
20.        var grid = $('#FooGrid').data('tGrid');
21.        var data = grid.data;
22. 
23.        if (data != null) {
24.            var rowCount = data.length;
25.            for (var i = 0; i < rowCount; i++) {
26.                var myRow = data[i].RowData;
27.                ToggleCheckBox(myRow, e.checked);
28.            }
29.        }
30.    }
31.</script>

0
Dimo
Telerik team
answered on 15 Sep 2014, 01:16 PM
Hello Fabio,

The data property of the discontinued MVC Grid object works only with client-side binding as stated in its documentation -

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-client-api-and-events.html#ClientProperties

We have provided some hints on your legacy application in this thread as an exception, but I am afraid we will not be able to do so anymore for the following reasons:

+ the Telerik Extensions for ASP.NET MVC no longer exist as a product and are officially no longer supported. This was announced in 2012 and there was a one-year maintenance and transition phase.

http://blogs.telerik.com/aspnetmvcteam/posts/12-05-31/kendo-ui-for-asp-net-mvc-and-the-telerik-extensions-for-asp-net-mvc.aspx

+ your account is currently not associated with any commercial license that could grant you the ability to benefit from our technical support service for production applications. You have an active trial for Kendo UI MVC, however, trials are intended for the sole purpose of evaluating a product before purchasing. Working on an existing production application cannot qualify as evaluation.

Theoretically, it is possible to use a new jQuery version with old Javascript code, which normally requires an old jQuery version. In this way you will be able to start migrating the Telerik MVC Extensions to Kendo UI MVC, and/or use them side-by-side.

http://docs.telerik.com/kendo-ui/install/prerequisites#what-to-do-when-an-older-jquery-version-is-required

Again, since this is a production application, you will need to purchase a commercial license before starting the integration process, in order to comply with our EULA.

http://www.telerik.com/purchase/license-agreement/aspnet-mvc

Regards,
Dimo
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.

Tags
General Discussions
Asked by
Fabio
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Fabio
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or