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

Posting a grid in form with checkboxes

3 Answers 78 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ale
Top achievements
Rank 1
Ale asked on 19 Mar 2014, 02:08 PM
I tried this solution (http://www.telerik.com/support/code-library/submit-form-containing-grid-along-with-other-input-elements), for posting a grid inside an html forum and work correctly.
But if I have a grid with checkboxes I don't understend how I can the true or false value.

I've tried this solution, but doesn't work.

columns.Bound(p => p.Inside).ClientTemplate(
"<input type='checkbox' #= (Inside=== true) ? checked : '' # />" +
"<input type='hidden' name='CAB[#= indexCAB(data)#].Inside' value='#= Inside#' />");

Someone can help me.

Thanks

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Mar 2014, 11:34 AM
Hi,

If the column value should be edited with the checkbox in the template then you should handle the checkbox click or change event and update the model. Please check this code-library which demonstrates this approach.

Regards,
Daniel
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Ale
Top achievements
Rank 1
answered on 28 Mar 2014, 01:35 PM
Thanks Daniel.
But now I have another problem with foreign key column binding.
I want to show Unit of measure Name inside grid, and when I post the form I want to store unit of measure Id.
I try to do this:

columns.ForeignKey(p => p.UoMInitialId, (IEnumerable)ViewData["UoMs"], "UoMId", "Name").ClientTemplate("#= Name#" +
 "<input type='hidden' name='UoM[#= index(data)#].UoMId' value='#= UoMInitialId#' />");

But I get error because Name doesn't exist.
How can I do that?
0
Accepted
Daniel
Telerik team
answered on 01 Apr 2014, 11:26 AM
Hi,

The foreignkey text field is not available in the data and by the default the foreignkey column uses the template to match the column value to the text. Since you are using a custom template, this logic should to be performed with custom code. I attached the code-library project modified to demonstrate one possible approach.

Regards,
Daniel
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Grid
Asked by
Ale
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Ale
Top achievements
Rank 1
Share this question
or