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

[Solved] Sorting and filtering column with ClientTemplate

0 Answers 15 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.
Andrey
Top achievements
Rank 1
Andrey asked on 31 Jan 2012, 03:13 PM
Hello,

I have a problem with column sorting and filtering in MVC Grid for the column which has ClientTemplate. Grid is defined as following (other columns omitted for brevity):
@(Html.Telerik().Grid<Models.ProjectTimeRegisterView>()       
        .Name("Gridd")
        .DataKeys(keys =>
                keys.Add(o => o.ProjectTimeRegisterId))
        .ToolBar(commands =>
        {
            commands.SubmitChanges();
        })
     .Columns(columns =>
     {
         columns.Bound(o => o.Project).ClientTemplate("<#= Project.ProjectName #>").Title(Strings.View_ProjectName);  
     }      
       .DataBinding(dataBinding => 
        {
            dataBinding.Ajax().Select("AjaxBinding""ProjectController").Update("UpdateAjaxBinding""ProjectController").Enabled(true);
        })
        .ClientEvents(events => events.OnEdit("onEdit").OnSave("onSave").OnLoad("onLoad"))
        .Sortable(sorting => sorting
                .SortMode(GridSortMode.MultipleColumn)
                .OrderBy(sortOrder => sortOrder.Add(o => o.Date).Descending())
                .OrderBy(sortOrder => sortOrder.Add(o => o.EmployeeFullName))
                )
        .Editable(editing => editing.Mode(GridEditMode.InCell).Enabled(!User.IsInRole(Mags.UserRoles.User)))
        .Pageable(paging => paging
                            .Enabled(true)
                            .PageSize(Mags.CommonConst.EntriesPerPage)
                                .Position(GridPagerPosition.Both))
        .Filterable(filtering => filtering.Enabled(true))
        .Groupable(grouping => grouping.Enabled(true))
        .Footer(true)
)

Model classes are as following (again, unimportant details omitted):
public class ProjectViewModel
{
    public string ProjectName { get; set; }
    public Guid ProjectGuid { get; set; }
}
public class ProjectTimeRegisterView  
{          
      [UIHint("Project"), Required]
    public ProjectViewModel Project { get; set; }  
}

When I try to sort data by that column, data is being sorted, but not in the correct order. For example after sorting in descending order, data might look like this:

Project "S"
Project A
Project C
Project B

Additionally, filtering doesn't work for that specific column - I can access filter widow for the column, but I can't select type of filter (i.e. "Starts with", "Contains" and e.t.c.), if I try to input some value into filter, I receive: "Error! The requested URL returned 500 - error"
Other columns can be filtered and/or sorted just fine.

Regards,
Andrey
Tags
Grid
Asked by
Andrey
Top achievements
Rank 1
Share this question
or