Hello.
I'm using NetAdvantage WebClient Trial 2009.2 to evaluation.
I want to implement "Ctrl-A" like function.
So I need to select all rows in xamWebGrid.
I try this code first:
foreach (var x in webgrid.Rows){ webgrid.SelectionSettings.SelectedRows.Add(x);}
but this is too slow.
So I tryed an other code:
webgrid.SelectionSettings.SelectedRows.AddRange(webgrid.Rows);
but it does'nt match Type of Arg.
Rows is RowCollection, not match SelectedCollectionBase<Row>.
Please tell me good performance way to do it.
Hi,
Could you provide more details about what exactly is the behavior that you consider slow?
Thanks,
Thanks for reply.1. I create a instance of XamWebGrid and set a event handler to KeyDown event.2. set Data (it has 10,000 rows) to XamWebGrid.ItemsSource.3. select all rows by XamWebGrid.SelectionSettings.SelectedRows.AddProcess takes about 20 sec at step 3.But, User can select all rows by mouse, "Click first row and Shift-Click last row".It takes about 0 sec.So, I say "too slow".I think SelectedRows.Add is too slow.Code is this:using System.Collections.Generic;using System.Windows;using System.Windows.Controls;using Infragistics.Silverlight.Controls;using Infragistics.Silverlight;namespace sample{ public partial class MainPage : UserControl { private XamWebGrid webGrid; public MainPage() { InitializeComponent(); } private void ButtonSearch_Click(object sender, RoutedEventArgs e) { webGrid = new XamWebGrid(); webGrid.EditingSettings.AllowEditing = EditingType.None; webGrid.SelectionSettings.CellClickAction = CellSelectionAction.SelectRow; webGrid.SelectionSettings.RowSelection = SelectionType.Multiple; webGrid.KeyDown += new System.Windows.Input.KeyEventHandler(onKeyDown); Grid.SetColumn(webGrid, 1); LayoutRoot.Children.Add(webGrid); List<sampleWebService.ITEM> testdata = new List<sampleWebService.ITEM>(); for (int i = 0; i < 10000; ++i) { sampleWebService.ITEM item = new sampleWebService.ITEM(); item.ATTR1 = i.ToString(); testdata.Add(item); } webGrid.ItemsSource = testdata; } private void onKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { // Ctrl-A if (e.Key == System.Windows.Input.Key.A && System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Control) { foreach (var x in webGrid.Rows) { webGrid.SelectionSettings.SelectedRows.Add(x); } } } }}
I've been able to reproduce your issue but unfortunately currently there isn't other way to make the selection programatically without this delay.
Regards,
Thanks Stoimen.
I hope fix type of "addrange" in next version NetAdvantage for Silverlight.
and I can write:
webGrid.SelectionSettings.SelectedRows.AddRange(webGrid.rows);
or, Add "ctrl-A" action such as DataGrid has.
Thanks.
Thanks, that's it.
The only problem is that I need to select all rows in all groups but this bit I can easily program myself.
Hi lemuriannn,
SelectAll functionality has been introduced in volume 11.2.
Here is a link to the sample demonstrating how it is use. And if you need any further details you could check this help page.
Don't hesitate to ask if you need any further assistance.
Were there any changes in recent versions of xamGrid addressing this issue? It would be great if Ctrl + A or at least .SelectAll() would be supported out-of-the-box.
I understood.
I think I wrote a code that throws away lazy evaluation.
Thanks your detailed explanation.
IList is better than IEnumerable?
Thank you for your advice!
So, when the xamWebGrid loads, it only accesses the data necessary for what it can currently display. As your scroll, it accesses more data and creates more Rows.
What you're doing here, is accessing all of your data and creating all of the Row objects associated with the Data at once.
So depending on the type of ItemsSource you're using, it could take some time to create the rows. Although once they're created, you won't have that problem, thus the performance improvement the second time around.
Note: i would recommend that you're at least using an IList for your ItemsSource, as that would give much better performance than just an IEnumerable.
-SteveZ