Error "Column does not belong to table" on Rebind

1 Answer 388 Views
Grid Persistence Framework
Harshad
Top achievements
Rank 1
Harshad asked on 13 Jul 2023, 09:31 AM

The RadGrid's AutoGenerateColumn is set to True. it can generate columns from the data source and load perfectly fine. Then I save the Grid Setting using the PersistanceManager. All good so far

The Grids data-source is actually taken from a View in database. only if I remove a column from the database View, and then try to load the grid along with saved settings then it fails because now the column that was there when saving settings no longer exists in datasource.

Here is how first settings are loaded 

RadPersistenceManagerCs.LoadState()

and then

RadGridCs.Rebind()

The error is thrown in .Rebind()

 


The RadPersistanceManager does not expose any property where i can see what was loaded

I wonder if it is possible to verify if columns in saved settings match columns in data-source some other way

 

Thanks

Harshad

1 Answer, 1 is accepted

Sort by
0
Accepted
Doncho
Telerik team
answered on 18 Jul 2023, 08:59 AM

Hi Harshad,

Saving and Loading the State of RadGrid is quite convenient when its initial structure remains unchanged. Rebinding the Grid to a modified data source that leads to a different number and instances of Grid Columns will make the default persistence non-working. I am afraid that such a scenario goes beyond the built-in RadGrid persistence.

A possible approach you can consider is to use the SaveSettings and LoadSettings server events exposed by the RadPersistenceManager to access the control settings of the Grid and manipulate them in a way you find feasible for the current case.

Check out how to work with the stored settings here:

To get a better idea of the Control hierarchy in the persisted control settings I would suggest you place a breakpoint in one of the server events and use the debugging capabilities of the VisualStudio to traverse the Controls collections beneath e.Settings argument. Find some debugging ideas here:

I hope you will find this information useful.

Kind regards,
Doncho
Progress Telerik

Heads up! Telerik UI for ASP.NET AJAX versions for .NET 3.5 and 4.0 are retired. Progress will continue shipping assemblies compatible with .NET 4.5 and later. See whether this affects your apps in this article.
Tags
Grid Persistence Framework
Asked by
Harshad
Top achievements
Rank 1
Answers by
Doncho
Telerik team
Share this question
or