Donuts
Donuts

Reputation: 2241

Using MVCGrid.net, how can I change sort/filter still have browser back button function

I'm using MVCGrid.net (http://mvcgrid.net). I want to change sort/filter options and still click back in my browser to return to the previous page. because this control leverages browser history, when i click back i return to the previous sort direction instead of the previous page. That's really great if I want that functionality -- don't get me wrong. but i don't always want that. it would be nice if there's a way to disable it (or circumvent it). is there?

Edit: Perhaps instead of using history.pushState() the axd, maybe using history.replaceState() would be a better experience?

Upvotes: 0

Views: 142

Answers (1)

Donuts
Donuts

Reputation: 2241

I forked this project on GitHub and added a .WithBrowserNavigationMode to the grid builder. I LOVE the feature of this control that I can come back from another page and still have my latest page/sort/filter preserved by leveraging browser history. But MOST of the time i only care about my last view. I don't want to click the back button to go to previous pages/sorts/filters.

Now if you only want to preserve the latest action that you did on a grid in your browser history, just do this:

MVCGridDefinitionTable.Add("YourGrid", new MVCGridBuilder<YourViewModel>()
    .WithBrowserNavigationMode(BrowserNavigationMode.PreserveLatestGridAction)

Currently only works with my fork of the code base unless/until my pull request is merged to master. Here's where to get it: https://github.com/johnpreed/MVCGrid.Net

Upvotes: 1

Related Questions