Select Row instead of selecting individual cell

Hi,

I am developing an application that has positions. I am using the GridGroupingControl to manage the positions. (using this one, because there are nested positions).

I want to select the entire row, and not only a specific cell. Is there a way, that creates a box around the entire row, instead around the cell?

Regards,
Nuno

3 Replies

AR Arulpriya Ramalingam Syncfusion Team December 27, 2017 12:07 PM UTC

Hi Nuno,  
  
Thanks for contacting Syncfusion support.  
  
By default, the selected records/rows will be highlighted with the SelectionBackColor (i.e. default blue color). In order to highlight the row with border, the QueryCellStyleInfo event can be used. In that event, the Borders property can be used to draw the borders to the row. We have created a simple sample as per your requirement. Please make use of below code and sample,  
  
Code example  
  
//To enable the Selection for the grid  
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.One;  
//To restrict the selection backcolor  
this.gridGroupingControl1.TableOptions.ListBoxSelectionColorOptions =GridListBoxSelectionColorOptions.None;  
  
//To avoid current cell on Selection  
this.gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions =GridListBoxSelectionCurrentCellOptions.HideCurrentCell;  
  
//Event subscription  
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo;  
  
//Event customization  
private void GridGroupingControl1_QueryCellStyleInfo(object sender,GridTableCellStyleInfoEventArgs e)  
{  
   if(this.gridGroupingControl1.TableControl.CurrentCell.HasCurrentCellAt(e.TableCellIdentity.RowIndex) && e.TableCellIdentity.ColIndex > 0)  
    {  
        //Draw the Top and Bottom borders for all the cells.  
        e.Style.Borders.Top = new GridBorder(GridBorderStyle.Solid, Color.Black,GridBorderWeight.Thin);  
        e.Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid, Color.Black,GridBorderWeight.Thin);  
        if (e.TableCellIdentity.ColIndex == 1)  
        {  
            //Draw laft border for the first cell  
            e.Style.Borders.Left = new GridBorder(GridBorderStyle.Solid, Color.Black,GridBorderWeight.Thin);  
        }  
        if (e.TableCellIdentity.ColIndex == this.gridGroupingControl1.TableDescriptor.Columns.Count)  
        {  
            //Draw right border for the last cell  
            e.Style.Borders.Right = new GridBorder(GridBorderStyle.Solid, Color.Black,GridBorderWeight.Thin);  
        }  
    }  
}  
  
  
Please let us know if you have any other queries.  
  
Regards,  
Arulpriya  




UN Unknown Syncfusion Team December 27, 2017 03:54 PM UTC

Hi Arulpriya Ramalingam,

I have issues with two parts of the code, one I've solved, another one, I don't know how to solve it.
You can see all of the code I have for the gridGroupingControl here: https://codeshare.io/5wqpp9

The right line was being draw one column before, I was able to change it, using the +1 in the following code:

        if (e.TableCellIdentity.ColIndex == this.gridGroupingControl1.TableDescriptor.Columns.Count + 1 )  
        {  
            //Draw right border for the last cell  
            e.Style.Borders.Right = new GridBorder(GridBorderStyle.Solid, Color.Black,GridBorderWeight.Thin);  
        }  



The issue I still have is that, when I select the row, it is selected in black!

If I comment the line:

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

It does not make a black selection, but it does select the cell. Here an image of the row completely black: https://ibb.co/b3if9w

Is there something wrong with my code? (i've posted the link above)




AR Arulpriya Ramalingam Syncfusion Team January 2, 2018 12:34 PM UTC

Hi Nuno,   
   
Thanks for your update.   
   
We have analyzed your code part. In your project, you have enabled both the selection options (i.e. AllowSelection and ListBoxSelectionMode) so that, the reported scenario occurred. By default, the current cell will be enabled when the selection is changed. In order to avoid the current cell when selection is changed, the ListBoxSelectionCurrentCellOptions property can be set as None. Please refer to the below code and UG,   
   
Code example   
   
//To disable the currentcell on selection   
this.gridGroupingControl1.TableOptions.ListBoxSelectionCurrentCellOptions =GridListBoxSelectionCurrentCellOptions.None;   
   
   
Note   
Please refer to the below KB to know more about the different selection modes in GridGroupingControl and let us know that the reason for using AllowSelection for select the rows with the ListBoxSelectionMode. So, that we could provide you an optimal solution for your case.   
   
   
Regards,   
Arulpriya  
 


Loader.
Up arrow icon