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); } } } }}
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.
I agree, that we need to make this simpler in the future, it was just a use case that we overlooked.
However, it is currently possible, with just a little bit of extra work, for now.
First, create a new class that derives from SelectedRowsCollection. We're going to do this, to expose a protected method, that will make it possible to make Selection quicker:
public class CustomSelection : SelectedRowsCollection
{
public void AddSelectItem(Row r)
this.SelectItem(r, true);
}
Now, in a button click, you can do the following:
private void Button_Click(object sender, RoutedEventArgs e)
CustomSelection src = new CustomSelection();
foreach (Row r in this.DataGrid1.Rows)
src.AddSelectItem(r);
this.DataGrid1.SelectionSettings.SelectedRows.AddRange(src);
Note, we do plan on making this easier to achieve in the future, but for now, i hope this helps.
-SteveZ
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.
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.
Regards,
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.