joeharrison714 / MVCGrid.Net

http://mvcgrid.net
MIT License
74 stars 55 forks source link

Grid not found on setFilter #78

Open mbausdorf opened 7 years ago

mbausdorf commented 7 years ago

Hi!

While using MVCGrid, I encounter an error, that the Grid that is shown, cannot be found when I try to apply a filter in code. The grid is drawn into the page using: @Html.MVCGrid("ListEntryGrid", new { filter = ViewBag.Filter })

Filtering happens on a button press, which calls the following function:

function applyFilters() {
        var region = $('#regionText').val();
        var jt = $('#jobTitleSelect').val();
        var a = $('#locationText').val();
        console.log(region);
        console.log(jt);
        console.log(a);

        MVCGrid.setFilters('ListEntryGrid', { Region: region, Location: a });
    }

I am using Bootstrap v4 (which should not impede the Grid) and jQuery 3.1.1 with Migrate. After the Grid not found: ListEntryGrid note, I also receive the following error: Uncaught TypeError: Cannot read property 'qsPrefix' of undefined(…)

Any idea what might cause this? Thank you!

Costax commented 7 years ago

I believe I had pretty much the same issue and I solved it by adding MVC.init() in a function when the document itself was ready.

<script type="text/javascript"> $(document) .ready(function() { MVCGrid.init(); }); </script>