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

[Solved] checkboxes always checked in Grid

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard Eikelboom
Top achievements
Rank 1
Gerard Eikelboom asked on 16 Mar 2011, 10:56 AM
Hi I have a checkbox in my grid. When I just bind (client side) the values to the column it shows true or false. So that's ok.
Now I thought lets make it a checkbox. Well, when i look at the examples on the site it shouldn't be that difficult.
Well, i tried a couple of things but the value is always checked in the grid/checkbox. Here is my piece of code:
columns.Bound(rvm => rvm.Assortiment
.HtmlAttributes(new { title = "Allow assortiment", style = "text-align:center" })
.ClientTemplate("<input type='checkbox' name='Assortiment' <#= Assortiment? checked='checked' : '' #>  disabled='disabled' />")

What am I doing wrong?
thanks in advance,
Gerard Eikelboom

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 16 Mar 2011, 11:05 AM
Hi Gerard,

It looks like you are checking a string value as if it is a bool value. In this case even the word "false" will return true, because it is a non-empty string. Please fix your condition check.

Regards,
Dimo
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Gerard Eikelboom
Top achievements
Rank 1
answered on 16 Mar 2011, 11:18 AM
Hi Dimo,
My properties in my model is a boolean.
I think the problem is that the properties are arrays eg(

 

 

public bool[] Assortiment

 


In my model i fill

Assortiment[0] with a boolen value.
And this is returned to the grid.
I think It can not handle this.
I think I need to create new properties with 1 value.

Correct?

Regards,
Gerard Eikelboom

0
Dimo
Telerik team
answered on 16 Mar 2011, 01:12 PM
Hello Gerard,

You can either use properties, which are not arrays, or try checking Assortiment[0] directly.

Regards,
Dimo
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Gerard Eikelboom
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Gerard Eikelboom
Top achievements
Rank 1
Share this question
or