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

[Solved] cell.text in CellAction

4 Answers 69 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.
Christoffer Stoll
Top achievements
Rank 1
Christoffer Stoll asked on 22 Dec 2010, 10:37 AM
Hi, 

I have a column that shows if an object is visible or not.
I want to show "Yes" or "No" in that column, but with the code below it only shows checkboxes.
It seems that cell.text is ignored.

Html.Telerik()
  .Grid(Model)
  .Name("MyGrid")
  .Columns(columns =>
  {                      
    columns.Bound(o => o.IsVisible).Title("Visible?");
  })
  .CellAction(cell=>
  {
    if (cell.Column.Member == "IsVisible")
    {
      cell.Text = cell.DataItem.IsVisible ? "Yes" : "No";
    }                      
  })
  .Render();


Is there another way to do this?

- Chris

4 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 22 Dec 2010, 11:14 AM
Hello Christoffer Stoll,

 Use the Template of the column to do that. There seems to be a bug which prevents the Text from working in RowAction.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Christoffer Stoll
Top achievements
Rank 1
answered on 22 Dec 2010, 11:30 AM
Will I be able to sort by that column if i use template?
0
Accepted
Atanas Korchev
Telerik team
answered on 22 Dec 2010, 01:43 PM
Hello Christoffer Stoll,

 Yes, you can sort a bound column for which a template is defined. Here is a sample implementation:

<% Html.Telerik()
  .Grid(Model)
  .Name("MyGrid")
  .Columns(columns =>
  {                     
    columns.Bound(o => o.IsVisible).Template(o =>
    {
    %>
        <%= o.IsVisible? "Yes" : "No" %>
    <%
    });
  })
  .Render();
  %>

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Christoffer Stoll
Top achievements
Rank 1
answered on 22 Dec 2010, 02:14 PM
I see. thank you, that works
Tags
Grid
Asked by
Christoffer Stoll
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Christoffer Stoll
Top achievements
Rank 1
Share this question
or