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

How to keep check box status on Grid after page change?

1 Answer 415 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 08 Jan 2021, 04:06 AM

Hello,

Does anyone have an idea how to keep check box check status when changed page? 

I added check box as a ( ClientTemplate) column, user can check or uncheck them. but check box's value was removed after page moving. How to keep those status?  Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 11 Jan 2021, 12:32 PM

Hi Zhihong,

Generally speaking if the checkbox is connected to a Property in your model, it should not be editable unless you are in edit mode. You can use the ClientTemplate to visually display a checkbox instead of true/false in your column, but in order to change the value(check/uncheck) you should edit the underlying data itself. Your client template could be something similar to this:

columns.Bound(p => p.BooleanProperty)
                    .ClientTemplate("<input type='checkbox' #= BooleanProperty ? 'checked= checked' : '' # disabled='disabled' ></input>");

And the update method in the controller:

public ActionResult Update([DataSourceRequest] DataSourceRequest request, MyModel model)
		{
			return Json(new[] { model }.ToDataSourceResult(request));
		}

If you are trying to do checkbox row selection, please have a look at the following demo.

Let me know if you have any questions.

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Georgi Denchev
Telerik team
Share this question
or