joeharrison714 / MVCGrid.Net

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

Paging error #45

Closed Vliedberger closed 7 years ago

Vliedberger commented 8 years ago

Hello,

Nice grid, works well! But I have an issue: when you perform a search which has multiple result pages, you can navigate to, for example, page 3.

So far, so good. But if you then apply a filter value, which has no results, then the following exception occurs:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at MVCGrid.Rendering.BootstrapRenderingEngine.RenderPaging(RenderingModel model, StringBuilder sbHtml) at MVCGrid.Rendering.BootstrapRenderingEngine.Render(RenderingModel model, GridContext gridContext, TextWriter outputStream) at MVCGrid.Engine.GridEngine.Run(IMVCGridRenderingEngine renderingEngine, GridContext gridContext, TextWriter outputStream) at MVCGrid.Engine.GridEngine.RenderUsingRenderingEngine(GridEngine engine, GridContext gridContext) at MVCGrid.Engine.GridEngine.RenderPreloadedGridHtml(HtmlHelper helper, IMVCGridDefinition grid, String gridName, Object pageParameters) at MVCGrid.Engine.GridEngine.GetBasePageHtml(HtmlHelper helper, String gridName, IMVCGridDefinition grid, Object pageParameters)

I hope you can resolve this error.

Thanks!

ghost commented 8 years ago

I am having the exact same issue. Can someone look into it or guide me how I can resolve this?

shefaliA commented 8 years ago

Can you specify exact scenario? I am using this grid and working perfectly fine for me

On Aug 7, 2016 11:52 AM, "Ibad Baig" notifications@github.com wrote:

I am having the exact same issue. Can someone look into it or guide me how I can resolve this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joeharrison714/MVCGrid.Net/issues/45#issuecomment-238093520, or mute the thread https://github.com/notifications/unsubscribe-auth/ATBD41rF2upNOVcPghljrhcXqaTkdHOxks5qdg0-gaJpZM4IDAE4 .

ghost commented 8 years ago

@shefaliA Following is the scenario:

  1. Open the page containing a grid with multiple entries
  2. Perform a search from Search textbox which gives multiple paged result
  3. Go to next page

Alternatively, if you just change the page and apply a filter it will also crash.

shefaliA commented 8 years ago

Gotcha. I am not using Global Filter.

My grid is working with all filters on initial Page Load but when I try to replicate your scenario , I am getting MVCGrid not defined error.

ghost commented 8 years ago

So, any solutions to this problem?

cesar-moya commented 8 years ago

I am having the same exact issue posted by Vliedberger, I am not using global filter but I am using FilterString on 2 columns. The issue happens indeed by doing the following: 1)with no filters on, show all results, say "100" records are shown 2)change to page 2 (assume 10 items per page) 3)add a filter that returns zero results

The issue is clearly happening when the grid is trying to render results for page 2 which doesn't exist due to the filter condition. ... any luck?

cesar-moya commented 8 years ago

Hi guys, I just added a quick fix for this solution and requested a pull. Please look at https://github.com/joeharrison714/MVCGrid.Net/pull/69

Thanks,

joeharrison714 commented 7 years ago

Thanks @odindarkester for the fix!

cesar-moya commented 7 years ago

No problem!