asp.netmodel-view-controllermvcgrid.net

mvcgrid.net unable to use toolbar


I'm working on a website with a feature that can sort users. I'm using mvcgrid.net libs but I can't figure it out. the toolbar doesn't work.

I used most of the basic source codes from mvcgrid.net but when i press something in the search bar it doesn't work or the items per page selection.


Solution

  • If you have specific code to take a look at, please post. Otherwise, here are a few things you can check:

    (1) Be sure you've applied the mvcgrid data attributes needed. For example, for a search field you might have these attributes:

    <input 
        type="search"
        data-mvcgrid-apply-additional="change"
        data-mvcgrid-type="additionalQueryOption"
        data-mvcgrid-option="search"
        data-mvcgrid-name="ContactGrid">
    

    (2) Be sure the value you chose for mvcgrid-option (in this example, "search") is then added when you configure the grid. For example:

    MVCGridDefinitionTable.Add("ContactGrid", new MVCGridBuilder<ContactViewModel>(defaults)
        .WithAdditionalQueryOptionNames("Search")
    ...
    

    (3) You then need to read the attribute (again in the grid config) in your .WithRetrieveDataMethod()

    string search = options.GetAdditionalQueryOptionString("search");
    

    I've forgotten step 2 in the past -- that's generally what has tripped me up.