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

GridGroupingControl - SelectedRecords

Thread ID:

Created:

Updated:

Platform:

Replies:

141768 Jan 3,2019 10:29 AM UTC Jan 3,2019 12:43 PM UTC WinForms 3
loading
Tags: GridGroupingControl
Loai
Asked On January 3, 2019 10:29 AM UTC

Hi,

I have a GGC, that is binded to a datatable. user can add, edit, delete records. No parent-child records.

What I need to do is to enable the user to select 1 or more rows by clicking and dragging the mouse on the rows header. this hilights the rows with black color-which is fine.
Then the user should click a button (Delete) to delete the hilighted rows.

Thanks for your help.


Arulraj A [Syncfusion]
Replied On January 3, 2019 11:26 AM UTC

Hi Loai, 

Thanks for using Syncfusion product. 

To delete the selected records, use the ListBoxSelectionMode to MultiExtended and call the Table.SelectedRecords.DeleteAll method. 

this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended; 


private void button1_Click(object sender, EventArgs e) 
{ 
    this.gridGroupingControl1.Table.SelectedRecords.DeleteAll(); 
} 
 


Arulraj A 


Loai
Replied On January 3, 2019 11:46 AM UTC

Hi,

Using ListBoxSelectionModewill give a different user experience. As the records will always be selected whenever the user clicks on any row. Is it possible to select the row(s) only when the user select them by using the row header?

Arulraj A [Syncfusion]
Replied On January 3, 2019 12:43 PM UTC

Hi Loai,  

Thanks for the update.  

To delete the selected records using AllowSelection, use the Row flag to select the row using its header and use the TableControl.Selections.GetSelectedRows method and delete the records manually from bottom to up.  

this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.Row; 
 
private void button1_Click(object sender, EventArgs e) 
{ 
    var range = this.gridGroupingControl1.TableControl.Selections.GetSelectedRows(true,true); 
 
    foreach (GridRangeInfo info in range) 
    { 
        for (int i = info.Bottom; i >= info.Top; i--) 
        { 
            Element el = this.gridGroupingControl1.TableModel.GetDisplayElementAt(i); 
            Console.WriteLine("Selected RowIndex : " + info.Top + " =====> " + el); 
            el.GetRecord().Delete(); 
        } 
    } 
    this.gridGroupingControl1.TableControl.Selections.Clear(); 
} 
 
  
Arulraj A  


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

;