We are using the MVC Extensions GridView with custom model binding to populate our grid. I have seen the post demonstrating that in the grid settings you can save/load the layout via the settings in the view model such as this:
Code Example 1 ( in the grid view setting)
C#settings.ClientLayout = (o, e) =>
{
if (layoutData != null)
{
e.LayoutData = layoutData;
}
};
However, this occurs after the actual binding of the grid which is happening on the controller action with:
Code Example 2 (In the controller action for "ViewModel")
C#viewModel.ProcessCustomBinding( binding.GetDataRowCount, binding.GetData, binding.GetSummaryValues, binding.GetGroupingInfo, binding.GetUniqueHeaderFilterValues );
The ClientLayout cannot be called before the actual binding to the view model. How can I set the layout data before I ProcessCustomBinding?
Hi Steven,
As you noted, the ClientLayout even is fired after databinding because it is necessary that the grid has data once the saved layout is being applied.
I will need some additional time to further discuss this behavior with my R&D team to find a possible workaround.
In the meantime, would you please clarify the reason for setting the layout before databinding?
I greatly appreciate your time and cooperation.
Hello Kate,
Our requirements specify that the end-user has the ability to save the report state, including showing/hiding columns, sorting, grouping, filters, etc. After it has been saved, using the Layout property, they can click on that "Report" and it will load it to the previous saved state.
Another part of our requirements say that we need to be distributive in our development using a n-tier architecture that separates our database from our front-end projects via WCF. Because we cannot expose the DBContext, we are required to do custom binding via the ProcessCustomBinding.
In addition, our queries could return as much as 100,000+ records and we are taking great detail that we are only working with visible records.
So, when the user clicks on a saved query, we want the grid to call back to the database with all the filters, sorting and grouping already applied.
Ideally, I would imagine there is some solution that allows for use to set the layout data on the client and then have the grid refresh so that as it hit the action, the view model would already have all the filters, grouping and settings applied so that we know what to grab from the DB.
Hi Steven,
Thank you for the clarification.
I forwarded this ticket to my R&D team for further analysis. We will update this thread once we have results to report.
I greatly appreciate your patience.