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

[Solved] Filter a bound column with client side template

2 Answers 129 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.
Philip Senechal
Top achievements
Rank 1
Philip Senechal asked on 07 Oct 2011, 08:35 PM
I have a bound column using a client template for an ajax enabled grid and I have filtering turned on for the grid, however, the filter box does not appear for the columns with a client template. Here is the grid code:

    @(Html.Telerik().Grid<RequestsViewModel>() //width 934, 917 with scrollbar
    .Name("requestGrid")
    .ToolBar(commands => commands.Insert())
    .DataKeys(keys => keys.Add(o => o.RequestId))
    .DataBinding(dataBinding => dataBinding.Ajax()
        .OperationMode(GridOperationMode.Client)
        .Select("_requestsSelect", "EIS", new { Queue = "All" })
        .Insert("_requestsInsert", "EIS")
        .Update("_requestsUpdate", "EIS")
        .Delete("_requestsDelete", "EIS"))
    .Columns(columns =>
    {
        columns.Bound(o => o.RequestType)
            .ClientTemplate("<a href='/EIS/Request/<#= RequestId #>'><img src='/Modules/InfoSource/Content/Images/Icons/application_go.png' align='left' alt='Request' /><#= RequestId #></a><br /><#= RequestType #>")
            .HeaderTemplate(
                @<text>Request #</text>
            )
            .HtmlAttributes(new { Style = "vertical-align:top;" });
        columns.Bound(o => o.RequestCategory)
            .HtmlAttributes(new { Style = "vertical-align:top;" });
        columns.Bound(o => o.RequestDate).Format("{0:MM/dd/yyyy}")
            .HtmlAttributes(new { Style = "vertical-align:top;" })
            .Filterable(false);
        columns.Bound(o => o.Requester)
            .ClientTemplate("<#= Requester #><br /><#= Department #>")
            .HeaderTemplate(
                @<text>Requester</text>
            )
            .HtmlAttributes(new { Style = "vertical-align:top;" });
        columns.Bound(o => o.Purpose)
            .HtmlAttributes(new { Style = "vertical-align:top;" });
    })
    .Editable(editing => editing.Mode(GridEditMode.InLine))
    .Sortable()
    .Selectable()
    .Filterable()
    .ClientEvents(events =>
        {
            events.OnDataBinding("bindToken");
            events.OnSave("saveToken");
            events.OnDelete("saveToken");
            events.OnEdit("gridEdit");
            events.OnLoad("gridLoad");
        })
    )

I was under the impression that as long as my column was bound to a field, I could filter on it. Can you let me know if this is correct and what I need to do to be able to filter on that column? Thanks.

2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 10 Oct 2011, 08:43 AM
Hello Philip,

.Filterable(false); should be the reason for RequestType field.

Greetings,
Nikolay Rusev
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
0
Philip Senechal
Top achievements
Rank 1
answered on 10 Oct 2011, 03:22 PM
.Filterable(false) isn't set for that column...it's on the next column which is RequestDate. I even tried setting .Filterable(true) to doubly make sure it was turned on for that column and that still didn't work.


UPDATE: I found the issue. If you specify a .HeaderTemplate, you seem to lose the ability to filter. I removed the HeaderTemplate and used data annotation to name the column in my model and now I can filter on those columns.
Tags
Grid
Asked by
Philip Senechal
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Philip Senechal
Top achievements
Rank 1
Share this question
or