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

[Solved] Formatting the column while using .ClientRowTemplate

2 Answers 168 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.
Jeff
Top achievements
Rank 1
Jeff asked on 24 Oct 2011, 10:46 PM
I have the following grid:
.DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                    .Select("_SelectDriverInfoEditing", "Brand")
                    .Update("_UpdateDriverInfoEditing", "Brand");
            })
.ClientRowTemplate(grid =>
            "<div class='employee-details'>" +
                "<dl>" +
                    "<dt>First Name:</dt><dd><#= FirstName #></dd>" +
                    "<dt>Last Name:</dt><dd><#= LastName #></dd>" +
                "</dl><dl class='t-widget'>" +
                    "<dt>City/State:</dt><dd><#= City #>, <#= StateName #></dd>" +
                    "<dt>Image count:</dt><#= ImageCount #></dd>" +                                    
                "</dl>" +
                "</dl><dl class='t-widget'>" +
                    "<dt>Coupon Status:</dt><dd><#= CouponStatus #></dd>" +
                    "<dt>Revenue:</dt><dd>$<#= Revenue #></dd>" +
                "</dl>" +
                "</dl><dn class='t-widget'>" +
                    "<dt>Notes:</dt><dd><#= Notes #></dd>" +                    
                "</dn>" +
            "<div class='commands'>" + grid.EditButton(null, GridButtonType.ImageAndText) + "</div>" +
            "</div>"
            )


Notice I have a column called CouponStatus. I also have an editor template for that column that translates into a dropdown while inline editing:
@(Html.Telerik().DropDownListFor(m => m)
        .BindTo(ViewBag.CouponStatuses)
)

Now all works fine. Question is, how does one format  the <#= CouponStatus #> while using .ClientRowTemplate. For example, how do I call any c# code on it (e.g Enum.Parse(Enum, the actual value of the property)). I tried using CellAction but the DataItem is null. Probably because I'm using AjaxBinding.

Any help is appreciated.

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 17 Apr 2012, 07:49 PM
I have the same issue, did you ever work this out? Any help would be appreciated.
0
Pechka
Top achievements
Rank 1
answered on 18 Apr 2012, 02:07 PM
Hi 

U can use ViewModels instead of trying to achieve the impossible. 
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Pechka
Top achievements
Rank 1
Share this question
or