1

I am displaying Grid using Grid.Mvc, sorting & paging are working but filters are not shown on the grid though I added ".Filterable(true).WithMultipleFilters()" to Grid. Below is my code. GridMvc.css is in place, Did I missing something? Thanks in advance!

               @Html.Grid(Model.List).Columns(c =>
               {
                   c.Add(o => o.key, true);
                   c.Add(o => o.listitem1).Titled("listitem1");
                   c.Add(o => o.listitem2).Titled("listitem2");
                   c.Add(o => o.listitem3).Titled("listitem3");
                   c.Add(o => o.listitem4).Titled("listitem4");
               }).WithPaging(10).Sortable(true).Filterable(true).WithMultipleFilters()
Chaitanya
  • 37
  • 2
  • 10

4 Answers4

2

I too had the same problem, few days back ,when i implemented mvc.grid in our project.

I have resolved the problem by adding the following code in the master page.

Code:

<html>
    <head>
        <link href="~/Content/MvcGrid/mvc-grid.css" rel="stylesheet">
    </head>
    <body>
        @RenderBody()

        <script src="~/Scripts/JQuery/jquery.js"></script>
        <script src="~/Scripts/MvcGrid/mvc-grid.js"></script>
        <script>
            $('.mvc-grid').mvcgrid();
        </script>
    </body>
</html>

And Apart from this , kindly make sure the path of files(mvc-grid.css,jquery.js,mvc-grid.js) are correct because that can create the Huge problem

One important thing here is , this line of code

        <script>
       $('.mvc-grid').mvcgrid();
            </script>

Should be place inside the body tag, I have tried to place that in head tag it is not working, if you place inside the body tag then only it will work.

If the information doesnt help you, no worries, they have given official installation documentation here:

http://mvc6-grid.azurewebsites.net/Home/Installation

Kindly follow that you will surely get it. All the best

Please let me know your thought or feedbacks.

Thanks

Karthik

Karthik Elumalai
  • 1,574
  • 1
  • 11
  • 12
1

You need to reference Gridmvc.css in your view.

User3250
  • 2,961
  • 5
  • 29
  • 61
0

I had this same problem, the gridmvc.js and gridmvc.css files were not loading and the problem with that is because I had them inside a @section{} function within a partial view. You can not use @section{} inside a partial view. Move it up in the tree and you will should be fine.

SharkyMe
  • 1
  • 1
0

I was struggling with the exact same issue, and this topic almost helped. Even there was something missing...

That thing was the path to the gridmvc file, you must adapt it to "your" project.

For instance, mines are located in different folders, different than the ones showed in the validated answer;

and the names are slightly different.

But once I corrected both lines, in my _layout.cshtml file the grid was perfectly working!

Hakeem
  • 23
  • 7