Search code examples
c#asp.net-mvchtmlmvcgrid

Sorting/ Filtering attributes not working in Grid.Mvc


The code for my Mvc Grid is shown below but for some reason the sortable and filterable attributes don't work as stated in the codePlex documentation. I am developing in .NET 4.5 using html5 and bootstrap.css:

@Html.Grid(Model.Item2).Named("ViewEntries").Columns(columns =>
                    {
                        columns.Add(c => c.entryName).Titled("Entry Name").Sortable(true).Filterable(true);
                        columns.Add(c => c.entryDate).Titled("Date").Sortable(true);
                        columns.Add(c => c.entryDetails).Titled("Details").Sortable(true);
                        columns.Add().Titled("Name1").RenderValueAs(c => Name1((int)c.name1)).Sortable(true).Filterable(true);
                        columns.Add().Titled("Name2").RenderValueAs(c => Name2((int)c.name2)).Sortable(true).Filterable(true);
                        columns.Add().Titled("Name3").RenderValueAs(c => Name3((int)c.name3)).Sortable(true).Filterable(true);
                    }).WithPaging(10)

Any help would be greatly appreciated, thanks.


Solution

  • So the reason that this wasn't working was that gridmvc.css wasn't actually being referenced in the layout file in the first place. As soon as I added it, filtering works as intended on the normally rendered columns.

    Now the problem I am having is getting filtering to work on columns that are rendered via a html helper but this just requires some research in to creating custom filterable widgets. Thanks for all the help guys =]