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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Count/get selected rows in detail view

Thread ID:

Created:

Updated:

Platform:

Replies:

148476 Oct 21,2019 07:48 PM UTC Oct 23,2019 10:52 AM UTC WinForms 3
loading
Tags: SfDataGrid
Josip
Asked On October 21, 2019 08:15 PM UTC

Hello,

How to get number of selected rows and and value from specific columns from selected rows when I have multiple selected rows in child grid but outside ChildGrid_SelectionChanged(), for example on Button click.

So far I have this:

SfDataGrid childGrid = new SfDataGrid();

 public From1()
        {
            InitializeComponent();
            childGrid.SelectionChanged += ChildGrid_SelectionChanged;
           
            InitGrid();
        }

 private void ChildGrid_SelectionChanged(object sender, Syncfusion.WinForms.DataGrid.Events.SelectionChangedEventArgs e)
        {
          
         
        }

 private void InitGrid()
        {              

            GridViewDefinition orderDetailsView = new GridViewDefinition();
            orderDetailsView.RelationalColumn = "IzdatnicaStavke";        
            childGrid.QueryRowStyle += ChildGrid_QueryRowStyle;         
            childGrid.Style.HeaderStyle.BackColor = Color.Yellow;
            childGrid.AutoGenerateColumns = false;
            childGrid.RowHeight = 21;
            childGrid.SelectionMode = GridSelectionMode.Extended;
            childGrid.SelectionUnit = SelectionUnit.Row;
            NumberFormatInfo nfi = new NumberFormatInfo();
            nfi.NumberDecimalDigits = 2;
            nfi.NumberGroupSizes = new int[] { };
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "IDIzdatnica", HeaderText = "ID", Visible = false });
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "SifraRD", HeaderText = "Šifra rd." });
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "OpisArtikla", HeaderText = "Opis/naziv" });
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "NazivGrupe", HeaderText = "Grupa" });
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "JedMjera", HeaderText = "Jed. mj." });                     
            childGrid.Columns.Add(new GridNumericColumn() { MappingName = "Kolicina", HeaderText = "Količina", NumberFormatInfo = nfi });           
            childGrid.Columns.Add(new GridTextColumn() { MappingName = "Napomena", HeaderText = "Napomena" });
         
            orderDetailsView.DataGrid = childGrid;
            this.gridIzdatnica.DetailsViewDefinitions.Add(orderDetailsView);
            this.gridIzdatnica.HideEmptyGridViewDefinition = true;

        }

Problem is that whatever I do the number of selected items are always 0 in childGrid.

Gowtham Gopalsamy [Syncfusion]
Replied On October 22, 2019 12:32 PM UTC

Hi Josip,  
    
Thank you for using Syncfusion controls.   
   
You can achieve your requirement “to get the selected items count for DetailsViewDataGrid” by using SfDataGrid.SelectedDetailsViewGrid.SelectedItems property.    
   
Please find the below code snippet.  
   
var count = this.sfDataGrid1.SelectedDetailsViewGrid.SelectedItems.Count;   
   
Please find the below sample link.  
    
   
Please let us know, if you require further assistance on this.   
    
Regards,   
Gowtham.   
 


Josip
Replied On October 22, 2019 04:59 PM UTC

Hi Josip,  
    
Thank you for using Syncfusion controls.   
   
You can achieve your requirement “to get the selected items count for DetailsViewDataGrid” by using SfDataGrid.SelectedDetailsViewGrid.SelectedItems property.    
   
Please find the below code snippet.  
   
var count = this.sfDataGrid1.SelectedDetailsViewGrid.SelectedItems.Count;   
   
Please find the below sample link.  
    
   
Please let us know, if you require further assistance on this.   
    
Regards,   
Gowtham.   
 


Thank you very much!

Farjana Parveen Ayubb [Syncfusion]
Replied On October 23, 2019 10:52 AM UTC

Hi Josip 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Farjana Parveen 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

Live Chat Icon For mobile
Live Chat Icon