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
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

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
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

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
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

Thank you Alex Hajigeorgieva!
This is exactly what I was looking for!