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

How to set the 'Select()' (checkbox) column of the MVC Grid?

6 Answers 2002 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ed
Top achievements
Rank 1
Ed asked on 07 Feb 2018, 06:12 PM

Hi,

Please can anyone show me how I can set the value of a Select() column in the MVC grid?

I have a class which contains a boolean field that I would like to use to tick / untick the checkbox that the Select() column renders, but I can find no information on how to do it!

 

Any help greatly appreciated - please let me know if you require more info.

Thanks..Ed

 

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 Feb 2018, 09:00 AM
Hello, Ed,

The Select column is only for selection purposes and it is not a bound column.

The Boolean fields can be bound to a standard column and the Grid will automatically make a checkbox in edit mode.

This could be observed in our editing demo:

https://demos.telerik.com/aspnet-mvc/grid/editing

Let me know if you need additional details on this matter.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ed
Top achievements
Rank 1
answered on 27 Feb 2018, 11:52 AM

Hi Stefan - thanks for the response.

I decided to implement a custom solution using jQuery and a ClientTemplate, as my requirements were not really inline with the demo.

I'm surprised you can't interact programmatically with the Select column though. Perhaps you could suggest this as an improvement to the framework, as it seems like an obvious thing to be able to do.

Thanks..Ed

0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 01 Mar 2018, 08:43 AM
Hi, Ed,

It is possible to preselect certain checked state of some rows, however, it should be done programmatically on the dataBound event of the Kendo UI Grid. We have a Knowledge Base article which shows how to do that at: 

https://docs.telerik.com/kendo-ui/knowledge-base/checkbox-selection-select-rows-on-load

In your scenario, you can check if the boolean property of the dataItem is true or false and select the row as desired:

dataBound: function(e) {
    var grid = this;
    var rows = grid.items();
    $(rows).each(function(e) {
      var row = this;
      var dataItem = grid.dataItem(row);
 
      if (dataItem.Discontinued) {
        grid.select(row);
      }
    });
},

https://dojo.telerik.com/ocOnIkEt

Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Ed
Top achievements
Rank 1
answered on 01 Mar 2018, 08:49 AM

Awesome, thanks - that's exactly what I was looking for!

Unfortunately I've already got a jQuery solution working, but will know for next time (and help others).

Cheers..Ed

0
Alex Hajigeorgieva
Telerik team
answered on 02 Mar 2018, 08:41 PM
Hello, Ed,

Thank you for your feedback.

I am glad the suggestion is appropriate. Hopefully, it will assist someone in the future indeed.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Victor
Top achievements
Rank 1
answered on 18 Oct 2020, 01:03 PM

Thank you Alex Hajigeorgieva!

 

This is exactly what I was looking for!

Tags
Grid
Asked by
Ed
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ed
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Victor
Top achievements
Rank 1
Share this question
or