joeharrison714 / MVCGrid.Net

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

How can I check if Grid definition already Exist? #62

Open shefaliA opened 8 years ago

shefaliA commented 8 years ago

I am trying to use MVCGrid for one of my MVC4 web application .I have few questions -

1. Is there any method exposed to check if Grid definition already exist in controller? I am trying to define grid in controller not in MVCConfig.cs but I am getting error if the action is hit second time -"Grid already exist".Please suggest

2. Repository are not populated until Action method is hit.I don't want to use DI in MVCConfig.cs,Is there any other way to call WithRetrieveDataMethod in controller separately not along Grid definition to avoid "Grid already exist" error ?

Your quick response is appreciated. Thanks for making this grid and making development easier

rajasanjeevkumar commented 8 years ago

You can check for existing grid using MVCGridDefinitionTable.GetDefinition method. This will throw an exception if there is no grid and returns the grid if there is grid. After getting the grid, set the RetrieveData property on the grid for changing the data elements.

shefaliA commented 8 years ago

You mean to say , I should check to see if an error is thrown in controller.Catch it and assume that Grid definition doesn't exist and add. But if any other generic exception is thrown then it will try to add grid definition again . Do we have any specific exception for grid to catch.Not sure how to handle other generic exceptions ?

Regards, Shefali Agrawal [773-666-3273]

On Thu, Aug 4, 2016 at 2:14 PM, rajasanjeevkumar notifications@github.com wrote:

You can check for existing grid using MVCGridDefinitionTable.GetDefinition method. This will throw an exception if there is no grid and returns the grid if there is grid. After getting the grid, set the RetrieveData property on the grid for changing the data elements.

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