This question is locked. New answers and comments are not allowed.
Hi,
This is what I am doing. I create a datatable using (look at http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx) and I set the item source to the grid which works fine. The reason using datatable being the columns that I want to display are never same and keep changing.
Now I want to add a ColumnGroupDescriptor. This is what I did
However my problem is at the code fails at "t
This is what I am doing. I create a datatable using (look at http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight_datatable_for_your_silverlight_applications.aspx) and I set the item source to the grid which works fine. The reason using datatable being the columns that I want to display are never same and keep changing.
Now I want to add a ColumnGroupDescriptor. This is what I did
DataTable dataTable =new DataTable();Code that fills the datathis.myGrid.ItemSource=dataTable;ColumnGroupDescriptor descriptor = new ColumnGroupDescriptor();descriptor.Column = this.myGrid.Columns[0];this.myGrid.GroupDescriptors.Add(descriptor);However my problem is at the code fails at "t
his.myGrid.Columns[0]" and says "Index was out of range. " which tells me the grid has not be completly
loaded because when I debug it says column count is 0 eventhough the itemsource is set to a datatable that
has 3 columns.
So I try to put the ColumnGroupDescriptor code in DataLoaded event of the grid.
But the error I get now is
"Cannot change ObservableCollection during a CollectionChanged or PropertyChanged event."
Can anyone please help me out.
Thanks
8 Answers, 1 is accepted
0
Accepted
Hello doc21,
The DataLoaded event fires after grouping as well, so you need to remove the event handler the first time it fires.
All the best,
Yavor Georgiev
the Telerik team
The DataLoaded event fires after grouping as well, so you need to remove the event handler the first time it fires.
All the best,
Yavor Georgiev
the Telerik team
0
doc21
Top achievements
Rank 1
answered on 24 Mar 2011, 07:26 PM
Thanks, it solved my problem
0
Jack
Top achievements
Rank 1
answered on 24 Nov 2011, 09:17 PM
Hi, I'm having the same problem, what do you mean by removing the event handler the first time it fires??
If I remove it the event handler, where would I put my columngroupdescriptor code?
Thanks
If I remove it the event handler, where would I put my columngroupdescriptor code?
Thanks
0
Hi Jack,
I hope it helps. Kind regards,
Maya
the Telerik team
The idea was to unsubscribe from the DataLoaded event once it is fired:
public MainPage() { InitializeComponent(); this.clubsGrid.DataLoaded += new EventHandler<EventArgs>(clubsGrid_DataLoaded); } void clubsGrid_DataLoaded(object sender, EventArgs e) { this.clubsGrid.DataLoaded -= new EventHandler<EventArgs>(clubsGrid_DataLoaded); //Implement your logic here. }I hope it helps. Kind regards,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Jack
Top achievements
Rank 1
answered on 25 Nov 2011, 03:07 PM
Hi,
Thank you so much, that was exactly what I was looking for.
Thanks!!!!
Thank you so much, that was exactly what I was looking for.
Thanks!!!!
0
Valery
Top achievements
Rank 1
answered on 19 Feb 2013, 06:45 AM
And why does DataLoaded event fire after changing the GroupDescriptors? why not KeyPressed or MouseClicked? When data is really loaded, there is DataLoading, then DataLoaded, and when GroupDescriptors, FilterDescriptors or SortDescriptors are changed, there is only DataLoaded. That's weird and inconsistent.
0
Hi,
Vlad
the Telerik team
DataLoaded event is raised every time you perform data-shaping operation like sorting, grouping, filtering, paging, etc. KeyPressed or MouseClicked are not something related to data.
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0
Valery
Top achievements
Rank 1
answered on 19 Feb 2013, 10:35 PM
from the event's name DataLoaded I would assume that it happens whenever data is loaded, not "shaped". If you declare as a feature that this event is also raised on changing filter, sort and group descriptors, this has to be explicitly documented and ideally backed by your reasons to do so. As well as the fact that DataLoadING event happens only on true data load operations (followed by DataLoaded). And MouseClicked and KeyPressed are definitely related to data because the user types or clicks to change filtering or sorting. What I'm saying is raising DataLoaded event on changing filters isn't obvious and I would call it a bug unless it's documented behavior.
