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

Making Checkboxes Read Only

4 Answers 1655 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.
Reid
Top achievements
Rank 2
Reid asked on 02 Mar 2012, 05:02 PM
Hi All,

I am trying to make the columns in the row of a Grid read-only.  I read about this here:
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-troubleshooting.html

And tried the code.  It does not work.   Here is the Markup ..
.Columns(columns =>                              
   {
       columns.Bound(eg => eg.Enabled).Width(100)
          .ClientTemplate("<input type='checkbox' disabled='disabled' name='Enabled' <#= Enabled? \"checked='checked'\" : \"\" #> />");
 
...

I also want to make the checkboxes in the row that have false values show as clear, not a dimmed grey checkmark.  Is that possible?


Any suggestions would be appreciated,
Reid

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 07 Mar 2012, 04:55 PM
Hello Reid,

I am not exactly sure if I understand your question. To make the column readonly you should use the ReadOnly configuration method. If you wish the checkbox not to be editable you should use the disabled attribute(like you are already doing), but the greyed style cannot be overriden. The only option I can think of to avoid this look is to position an image over the checkbox.

All the best,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Reid
Top achievements
Rank 2
answered on 08 Mar 2012, 12:15 AM
Daniel,

Is there a way to format it to just show Yes or No.  Not sure what you mean by ReadOnly configuration.  If you mean a data annotation I believe that would prevent the field from being updated in edit mode.  So in display mode there should be no editing of the "Enabled" column but in the Edit form the Administrator using this app would need to check that box.

Thanks,Reid
0
Reid
Top achievements
Rank 2
answered on 08 Mar 2012, 01:40 PM
Daniel,

I have tried at least 5 different posts with code as to how to simply get it to display a "Yes" or "No" when this column displays.

This link should do it but it does not work
:http://www.telerik.com/community/forums/aspnet-mvc/grid/changing-a-bool-field-to-display-yes-no.aspx

This is a Ajax bound grid.  I have tried the following :
.Columns(columns =>                           
 {
   columns.Bound(eg => eg.Enabled).Width(130)
    .ClientTemplate("<# if(Enabled) { #>Yes<# } else {#>No<# } #>");


.Columns(columns =>                           
 {
   columns.Bound(eg => eg.Enabled).Width(130)   
      .ClientTemplate("<#= eg.Enabled? 'Yes' : 'No' #>");


.Columns(columns =>                           
 {
   columns.Bound(eg => eg.Enabled).Width(130)   
      .ClientTemplate("<# if(Enabled) { #>Yes<# } else {#>No<# } #>");


All of the above compile and run but have no affect on the display of the checkbox.

Not sure where to go from here.

Thanks,
Reid








0
Daniel
Telerik team
answered on 08 Mar 2012, 10:40 PM
Hello again Reid,

You should use the property name without the prefix in the client expression in order to get its value. For example:
.ClientTemplate("<#= Enabled ? 'Yes' : 'No' #>");
If this doesn't resolve the problem, I will appreciate if you could send a small runnable project so I can investigate further.

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Reid
Top achievements
Rank 2
Share this question
or