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

[Solved] Make a grid Sortable() on column with template?

1 Answer 150 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.
Julien
Top achievements
Rank 1
Julien asked on 31 Jan 2012, 11:17 AM
Hi,

I've several columns in a table which have a main information and a related information, for one "case" of my grid.

I set the grid .Sortable(), but it seems it cannot know on which column it has to sort(and it's normal).

how can I indicate which data has to be sorted on each colum?

Actually I've most of my column looking like this:
columns.Template(@<text><p><strong>@item.Format.Name</strong></p><p>@item.Format.Width x @item.Format.Height mm</p></text>)
.HeaderTemplate(@<text>Format</text>);

Here by example, I want to sort on @item.Format.Name for this column. How can I do this? I assume this will be the same problem for filtering.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 31 Jan 2012, 12:19 PM
Hello Julien,

Yes filtering and sorting work only for bound columns. In your case it should look like this:
columns.Bound(m=>m.Format.Name).Template(@<text>
    <p><strong>@item.Format.Name</strong></p>
    <p>@item.Format.Width x @item.Format.Height mm</p>
</text>)
.Title("Format");

Also if you set the header template you will lose the sorting functionality. In your case you should set the Title instead.
I hope this helps. 

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
Tags
Grid
Asked by
Julien
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or