thanks in advance
9 Answers, 1 is accepted
You can use the Items property of RadGridView.
Greetings,
Veselin Vasilev
the Telerik team
I have a similar problem, but I'd like to get filtered (and/or sorted) rows for the entire grid, not only visible page. Items property contains only visible items, ItemsSource - initial collection bound to a grid, neither sorted, nor filtered.
Thank you,
Irene
Can you post more info how the grid is bound (and paged) at your end? If this is server-side paging you will unable to get the other items since they are not available.
Regards,Vlad
the Telerik team
Thank you for a quick reply. The grid is bound to the "GridData" -Telerik DataTable (the "replacement" of ADO.NET DataTable which was graciously created by Vladimir Enchev from Telerik) All the data is fully downloaded from the server before binding to the grid. Here is XAML:
<axceler:xcGridView x:Name="grdData" AutoGenerateColumns="True" SelectionMode="Extended"
AutoExpandGroups="True" CanUserDeleteRows="False" CanUserInsertRows="False" ItemsSource="{Binding Path=GridData, Mode=OneWay}" DataLoadMode="Asynchronous"
ScrollViewer.VerticalScrollBarVisibility="Auto" AlternationCount="2" CanUserSelect="False" Visibility="Collapsed"
MaxHeight="500" RowIndicatorVisibility="Collapsed">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<cmd:EventToCommand PassEventArgsToCommand="True"
Command="{Binding Path=GridSelectionChangedCommand, Mode=OneWay}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="{Binding Path=xcUIResource.Selected, Source={StaticResource LocalizedStrings }}" DataMemberBinding="{Binding Selected, Mode=TwoWay}" UniqueName="Select" TextAlignment="Center">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<CheckBox x:Name="chckSelected" IsChecked="{Binding Selected, Mode=TwoWay}" Checked="chckSelected_Checked" />
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</axceler:xcGridView>
<axceler:xcDataPager x:Name="radDataPager" PageSize="15" Source="{Binding Items, ElementName=grdData}" Visibility= "Collapsed"
Margin="0 1 0 10" />
axceler:xcGridView and axceler:xcDataPager are subclasses of RadGridView and RadDataPager with no extra functionality added so far.
Thanks a lot for looking into this issue.
Irene
To my regret there is no direct way to get the paged filtered data in RadGridView. Can you tell us at what stage you want to take that data? Is it on button click or something else?
One of the possible solutions would be to work directly with your data source. You can convert it to queryable by calling the AsQuearyable() method and then add the RadGridView's FilterDescriptors collection to its Where clause. Similarly you can add the SortDescriptors to the Sort method and now you will have all the data that match these criteria.
Let me know if this helps.
Best wishes,
Veselin Vasilev
the Telerik team
Thank you for your answer!
Yes I want the data on button click event. I am using the grid data as a feed to a chart and for users would be natural to expect that after sorting and filtering the chart will show sorted and filtered data. I was thinking about using queryable source, but thought I could have a simple way out :-).
Thanks,
Irene
// setup a dummy dataset DataSet ds = new DataSet(); DataTable dt = new DataTable(); // add the columns you want from the radgrid dt.Columns.Add(new DataColumn("ColumnName1")); dt.Columns.Add(new DataColumn("ColumnName2")); dt.Columns.Add(new DataColumn("ColumnName3")); // etc ds.Tables.Add(dt); int currentPage = radgrid.CurrentPageIndex; // disable paging and rebind so you get all items radgrid.AllowPaging = false; radgrid.Rebind(); foreach (GridItem item in radgrid.MasterTableView.Items) { if (item is GridDataItem) { // import the row to the dummy dataset dt.ImportRow((item.DataItem as DataRowView).Row); } } // re-enable paging radgrid.AllowPaging = true; radgrid.CurrentPageIndex = currentPage;At that point your dataset will contain the filtered and sorted data from the radgrid. It's kind of hacky, though.
Thank you, Alex.
It seems like your code pertains to ASP.NET, not Silverlight....
Irene
