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

[Solved] Limiting columns in the Edit View that are visible in the Model and ClientRowTemplate

5 Answers 65 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 11 Mar 2012, 08:03 PM
Hi All,

In a Grid that is using a ClientRowTemplate there is a column bound for "Enabled".  A boolean column in the model.  In the ClientRowTemplate I would like to make the Enabled display a "Yes" or "No" and the Edit Popup form to use a checkbox as it is.

I created a wrapper property in the model of type string that is set in the set method of the class so the value is in use in the RowTemplate as "EnabledDisplay".  Question is, given the template code below how can the Enabled property be formated in a "Yes" and "No" way or how can I hide "EnabledDisplay" (or any other field) from the Edit form?


.ClientRowTemplate(grid =>
  "<div class='user-details'>" +           
       "<h3 class='t-widget'><#= UserName #></h3>" +
                 
          "<dl class='t-widget'>" +
             "<dt>Title:</dt><dd><#= Title #></dd>" +
             "<dt>Phone:</dt><dd><#= PhoneNumber #></dd>" +
          "</dl>" +                                                   
                                                     
           "<dl>" +
 
               <dt>User Name:</dt><dd><#= UserName #></dd>" +
               "<dt>Email:</dt><dd><#= Email #></dd>" +
                "<dt>Enabled:</dt><dd><#= Enabled #></dd>" +
            "</dl>" +
                                                                                          
                "<div class='commands'>" +
                 grid.EditButton(null) + grid.DeleteButton(null) +
            "</div>" + "</div>")





Thanks,

Reid

5 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 12 Mar 2012, 05:29 PM
Hello Reid,

Basically in such cases you can use the ternary operator. For example in this demo the following line of code:
.ClientTemplate("<input type='checkbox' disabled='disabled' name='Discontinued' <#=Discontinued? checked='checked' : '' #> />");
checks if the value of the Discontinued property is true it adds a checked attribute to the input.
So in your case it should look like this:
<#= Discontinued? 'yes' : 'no' #>


Regards,
Petur Subev
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 12 Mar 2012, 08:29 PM
Ok Thanks Petur,

Appreciated.
Reid
0
Reid
Top achievements
Rank 2
answered on 12 Mar 2012, 08:42 PM
Petur,

Actually I am not sure if I understand you on this.

I have a column that exists in the model and outputs on the ClientTemplate using Ajax binding and events.  I want to supress that column on the Edit View Template that shows when the grid is set to Pop-Up for edting a record.

Thanks,

Reid
0
Accepted
Petur Subev
Telerik team
answered on 13 Mar 2012, 02:29 PM
Hi Reid,

To make that particular property (column) visible for display and invisible in edit you can add the [HiddenInput(DisplayValue=false)] in your model definition.

Greetings,
Petur Subev
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 13 Mar 2012, 10:04 PM
Thanks Petur,
Works.

Reid
Tags
Grid
Asked by
Reid
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Reid
Top achievements
Rank 2
Share this question
or