We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Multi-select in GridDataBoundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

33739 Aug 25,2005 09:31 AM UTC Nov 12,2005 11:18 PM UTC WinForms 11
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On August 25, 2005 09:31 AM UTC

Hi! I''ve been looking and searching through the forums and I haven''t found an answer to my problems yet! I have a lookup-form with a griddataboundgrid on it... it gets filled with a dataset which contains one datatable. extended multi select is enabled. now when I select multiple rows, I need to get the associated datarows out of my dataset when I press the ok button so that I can pass a DataRowCollection to the form that has called the lookup-form. this.datagrid.selections.getselectedrows() gives back a gridrangeinfolist but where do I get my datarows from there on?? or am I looking at the wrong place? any help would be greatly appreciated :)

Administrator [Syncfusion]
Replied On August 25, 2005 10:51 AM UTC

Using GetSelectedRows will give you a GridRangeInfoList. From the GridRangeInfoList, you get GridRangeInfo objects that are row ranges, so range.Top and Range.Bottom will give you the the indexes of the selected rows in the grid. So, you have a collection of grid rowIndex''s. To get the corresponding position in your datasource, you use this method. int position = this.grid.binder.RowIndexToPosition(rowIndex); If you are not supporting sorting or filtering in your data source, then you can just use this position value to index your data source (DataTable.Rows[position]). But if you are allowing sorting/filtering, to get the datarow from the position, you need to go through the DataView associated with the grid and your datasource.

Administrator [Syncfusion]
Replied On August 25, 2005 12:15 PM UTC

at first sight, it works like a charm! thanks a lot!!! :)

Keyur Patel
Replied On September 3, 2005 12:07 AM UTC

I was having the same problem. What if the rows selected are not sequential (i.e. they were selected using clicks)? The top and bottom is not what I need, I need a list of rows that were selected.

Administrator [Syncfusion]
Replied On September 3, 2005 12:27 AM UTC

You get the selected rows the same way. The GridRangeInfoList gives you a collection of GridRangeInfo objects. From each one of these GridRangeInfo objects, you can use the range.Top and range.Bottom to find the rows contained in that particular range. If Top equals Bottom, then that would represent a single row, selected with a click. If you clicked 5 individual rows to select them, there would be 5 GridRangeInfo objects where Top == Bottom for each range.

Babak Keradman
Replied On November 12, 2005 08:29 PM UTC

This does not seem to work well when the grid has been grouped. For instance, if the GridRangeInfo is telling me that I am "R14", there doesn''t seem to be a way to translate that to the index in the datasource, because there may be many grouped rows. R14 could be index 75 if I have many rows grouped. Is there a way around this?

Administrator [Syncfusion]
Replied On November 12, 2005 09:48 PM UTC

The above discussion was for a GridDataBoundGrid. It uses the selection support in the GridControlBase class. This class has no knowledge of the special nature of the GridGroupingControl. That control has its own selection support that differs from the support in the base class. To use it, set: grid.TableOptions.AllowSelections = GridSelectionFlags.None; grid.TableOptions.ListBoxSelectionMode = Selection.Mode.One; //anything other than None Then you can use the this.gridGroupingControl1.Table.SelectedRecords collection to access the selected records.

Babak Keradman
Replied On November 12, 2005 10:04 PM UTC

When I set my options to: grid.TableOptions.AllowSelections = GridSelectionFlags.None; grid.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended; //or MultiSimple this.gridGroupingControl1.Table.SelectedRecords always returns a count of 1 selected record, no matter how many records that I select.

Administrator [Syncfusion]
Replied On November 12, 2005 10:32 PM UTC

I do not see this problem in this sample using version 3.3. Can you see this problem in this sample? http://www.syncfusion.com/Support/user/uploads/GGC_Sel_7f950c4c.zip

Babak Keradman
Replied On November 12, 2005 10:41 PM UTC

There are two differences between our implementation and the sample. 1-) We do not use this.gridGroupingControl1.DataSource; but rather this.gridGroupingControl1.ControlDataSet 2-) Our datasource is a DataSet not a DataTable Other than that my code looks the same as the sample. I put in the following test button: Syncfusion.Grouping.SelectedRecordsCollection selectedRecords; selectedRecords = grdTOPWatchList.Table.SelectedRecords; MessageBox.Show(selectedRecords.Count + " selected record(s)..."); No matter how many records I select, the count is always only one.

Administrator [Syncfusion]
Replied On November 12, 2005 11:08 PM UTC

Are you using the Windows Forms GridGroupingControl or the web GroupingControl? The web forum is here. http://www.syncfusion.com/Support/Forums/forum.aspx?ForumID=14

Administrator [Syncfusion]
Replied On November 12, 2005 11:18 PM UTC

One other comment is that is you are using nested tables, then there is a SelectedRecords selection for each table. Console.WriteLine(this.gridGroupingControl1.Table.SelectedRecords.Count); string s = this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableName; Console.WriteLine(this.gridGroupingControl1.GetTable(s).SelectedRecords.Count);

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;