deadlock
deadlock

Reputation: 21

Is it possible not to configure grid setting on startup?

Let say I have multiple pages, one of those is main page that simply display logo styles, text etc, the other pages uses multiple grids, do I have to configure/retrieve the data for other pages on startup even if this is not necessary?

Upvotes: 2

Views: 247

Answers (1)

Amr Elgarhy
Amr Elgarhy

Reputation: 68952

Yes you can do that easily in any controller action method and based on whatever parameters and logic you want, and it is the same as you do in the start up configuration.
The only issue I faced while doing that is in this line:

MVCGridDefinitionTable.Add("gridName", def);

because this lines will throw an error if the grid already added and defined, and the bad news that the solution I found so far is not a good solution as you can see in this post: https://github.com/joeharrison714/MVCGrid.Net/issues/62

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.

Something like this:

//check if grid already exist
// https://github.com/joeharrison714/MVCGrid.Net/issues/62
try
{
    MVCGridDefinitionTable.GetDefinition<YOURTYPE>("gridName");
}
catch (Exception ex)
{
    MVCGridDefinitionTable.Add("gridName", def);
}

*** If you got a better way please share it.

Upvotes: 1

Related Questions