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

MVC Grid Column with ActionLink and sortable

3 Answers 133 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.
prashant
Top achievements
Rank 1
prashant asked on 11 Jul 2011, 11:56 PM

I'm building a column using column template using the code below.

columns.Template(o =>{%><%= Html.ActionLink(o.ClaimsActivityId.ToString(), "Index", "ClaimActivityDetail", new { claimsActivityId = o.ClaimsActivityId.ToString() }, null)%><%
                                            }).Title("Ref #");

I'm able to build the ActionLink column successfully , but the column is loosing the sorting capability.
I need help with 2 things:

1) How to make the ActionLink column sortable.
2) How to add css to the column header and column data.

Thanks

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 12 Jul 2011, 07:38 AM
Hi Prashant,

In order a column to be sortable, a bound column should be used, which also have a templates capabilities.

You may use column's HtmlAttributes and HeaderHtmlAttributes properties to apply custom css. More information can be found here.

All the best,
Rosen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
prashant
Top achievements
Rank 1
answered on 12 Jul 2011, 05:09 PM
Thanks for your reply Admin

 How can I make action Link column sortable, please provide a sample code.

<% Html.Telerik().Grid(Model)
       .Name("Orders")
       .Columns(columns =>
       {
          //Column which will display the OrderID property of the Order
          columns.Bound(o => o.OrderID);

          //Column which will display the OrderDate property. The header will display "Order"
          columns.Bound(o => o.OrderDate).Title("Order");

          //Template column which shows an action link
          columns.Template(o => 
          {
              %>
                  <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID }) %>
              <%
          }).Title("Edit");
       })
       .Render();
%>


Thanks !!!
0
Rosen
Telerik team
answered on 13 Jul 2011, 07:26 AM
Hi Prashant,

As I have mentioned in my previous message you should convert the Template column to a Bound one:

columns.Bound(o => o.OrderID).Template(o =>
{
    %>
        <%= Html.ActionLink("Edit", "Home", new { id = o.OrderID })%>
    <%
}).Title("Edit");

Greetings,
Rosen
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Grid
Asked by
prashant
Top achievements
Rank 1
Answers by
Rosen
Telerik team
prashant
Top achievements
Rank 1
Share this question
or