Hi.
I'm having problems with RadListView, regarding the change of DataSource.
First problem : using an Interface type
Here is what I do : I am using RadListView, in details mode, to list objects, implementing a common interface, let's say IListItem. As a DataSource, I am using a IListItem[ ].
Let's say I have an array containing two or more types implementing the interface : TypeA and TypeB.
Using that array as the datasource will do nicely.
If I use an array containing only objects of TypeA, the RadListView will create not only columns based on IListItem, but also add columns based on TypeA. Is this a desired behavior? I would expect only to see columns based on IListItem.
I have been able to work around this with ColumnCreating event, adding :
Second problem :
Assuming the same conditions (interface type IListItem, two types implementing it TypeA and TypeB)
At first, the DataSource is defined with a large array, containing both TypeA and TypeB. After a search (the search is full text and made on sqlserver, a new array is then constructed with new objects), the datasource is changed this way :
If it occurs that the new array contains only TypeA, I get a System.Reflection.TargetInvocationException. The stack trace shows the last call from Telerik code comes from : Telerik.WinControls.Data.RadListSource`1.GetBoundValue.
And it looks like the reflection exception is trying to access TypeB directly, instead of using the interface (my exception is in french, but it would probably be object does not match target type). It start in my ColumnCreating method, the event being fired after the datasource update.
That looks a bit to what is described in this thread :
http://www.telerik.com/forums/refresh-data-in-radlistview-problem#Hlgoam9vfkaKvqTGSWdttg
My understanding was that the bug was fixed, but I have been able to work around it this way :
before updating the DataSource. Not clearing the Columns seems to affect the AutoSizeMode defined in ColumnCreating because the columns are all too small after a datasource change. Even with Columns.Clear, the AutoSizeMode is not perfect, but it is still better. One of my columns looks a bit too small, maybe adjusting only at first time?
Thanks!
I'm having problems with RadListView, regarding the change of DataSource.
First problem : using an Interface type
Here is what I do : I am using RadListView, in details mode, to list objects, implementing a common interface, let's say IListItem. As a DataSource, I am using a IListItem[ ].
Let's say I have an array containing two or more types implementing the interface : TypeA and TypeB.
Using that array as the datasource will do nicely.
If I use an array containing only objects of TypeA, the RadListView will create not only columns based on IListItem, but also add columns based on TypeA. Is this a desired behavior? I would expect only to see columns based on IListItem.
I have been able to work around this with ColumnCreating event, adding :
switch
(e.Column.FieldName)
{
...
default
:
e.Column.Visible =
false
;
}
Second problem :
Assuming the same conditions (interface type IListItem, two types implementing it TypeA and TypeB)
At first, the DataSource is defined with a large array, containing both TypeA and TypeB. After a search (the search is full text and made on sqlserver, a new array is then constructed with new objects), the datasource is changed this way :
radListView1.DataSource = array;
If it occurs that the new array contains only TypeA, I get a System.Reflection.TargetInvocationException. The stack trace shows the last call from Telerik code comes from : Telerik.WinControls.Data.RadListSource`1.GetBoundValue.
And it looks like the reflection exception is trying to access TypeB directly, instead of using the interface (my exception is in french, but it would probably be object does not match target type). It start in my ColumnCreating method, the event being fired after the datasource update.
That looks a bit to what is described in this thread :
http://www.telerik.com/forums/refresh-data-in-radlistview-problem#Hlgoam9vfkaKvqTGSWdttg
My understanding was that the bug was fixed, but I have been able to work around it this way :
radListView1.Columns.Clear();
radListView1.DataSource =
null
;
before updating the DataSource. Not clearing the Columns seems to affect the AutoSizeMode defined in ColumnCreating because the columns are all too small after a datasource change. Even with Columns.Clear, the AutoSizeMode is not perfect, but it is still better. One of my columns looks a bit too small, maybe adjusting only at first time?
Thanks!