This is a migrated thread and some comments may be shown as answers.

Add/Remove column in DataTable not propagated to RadGridView

0 Answers 62 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
New
Top achievements
Rank 1
New asked on 18 Jan 2013, 05:18 PM
I am using version 2012.1.326.35.

I have a RadGridView with a DataTable dt as ItemsSource. The RadGridView appears to render the initial column specification correctly and also recognize the row changes. However, when I update the columns, then I notice that addition and removal of columns are not recognized in the RadGridView.

This is how I refresh my DataTable:

================================================
public void updateData(SomeCustomDataSource data)
dt.Clear();
int num_cols = model.Columns.Length;
for (int i = 0; i < num_cols; i++)
{
SomeCustomColumn c = data.Columns[i];
if (!dt.Columns.Contains(.Name)) // Adding columns not previously existing
{
DataColumn col = CreateDataColumn(c);
dt.Columns.Add(col);
}
}
dt.AcceptChanges();
RefreshGrid(); // Plain old OnPropertyChanged("DataSource");
================================================
I'd like to note that this is just some dummy code. In the actual code I wanted to use, I called dt.Columns.Clear() and re-added every single column on data update. And what happens in that case is that none of the columns changed but when I click on the "click to add new row" row insertion thing, I get a "[Column] does not belong to Table [Table]" ArgumentException, which implies the internal data is not actually refreshed in the RadGridView even though the rows are updated correctly.

Again, if you want my license key in order to provide support, I'd be happy to provide it.

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
New
Top achievements
Rank 1
Share this question
or