How to change record status by CheckBox click

I have list of clients.
I'm using GridGroupingControl, but I have using it like a ListBox wit one row selection.
Then I have:
  <TableOptions>
    <ListBoxSelectionMode>One</ListBoxSelectionMode>
    <ListBoxSelectionCurrentCellOptions>HideCurrentCell</ListBoxSelectionCurrentCellOptions>
  </TableOptions>
One of column have value 0/1 then I put on this column CellType = CheckBox

Now, when user click on this checkbox I have change value form 0 to 1 in database.

I try:
- TableControlCheckBoxClick - not working, maybe because 
    <AllowNew>false</AllowNew>
    <AllowRemove>false</AllowRemove>
    <AllowEdit>false</AllowEdit>
- TableControlCellClick - problem because when I use:
GridCurrentCell cc = tableControl.CurrentCell;
cc.ColIndex is 0

In attachement is definition of grid




Attachment: ClientGrid_e2628727.7z

5 Replies

SN Sindhu Nagarajan Syncfusion Team March 6, 2018 11:51 AM UTC

Hi Krzysztof,   
   
Thanks for contacting Syncfusion support.   
   
We can understand your scenario. In our GridGroupingcontrol architecture, if you set the ListBoxCurrentCellOptions as HideCurrentCell, you cannot edit the cell values because there is no activated current cell. So, you cannot update the cell values when ListBoxCurrentCellOptions as HideCurrentCell. In order to overcome this scenario, cellvalue can be set by using Record.SetValue() method in TableControlCheckboxClick  event. Please make use of the code and sample below,   
  
Code Example 
this.gridGroupingControl1.TableControlCheckBoxClick += GridGroupingControl1_TableControlCheckBoxClick; 
 
private void GridGroupingControl1_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e) 
{ 
     if (e.TableControl.Table.CurrentRecord != null) 
     { 
         var cellValue = e.TableControl.Table.CurrentRecord.GetValue("Checkbox"); 
         if (cellValue.ToString() == "1") 
             e.TableControl.Table.CurrentRecord.SetValue("Checkbox", 0); 
         else 
             e.TableControl.Table.CurrentRecord.SetValue("Checkbox", 1); 
     } 
} 
  
  
   
Please refer to the UG link and KB link,   
   
    
   
   
Regards,   
Sindhu    
 



KA Krzysztof Adamowicz March 7, 2018 11:31 PM UTC

TableControlCheckBoxClick not working in my project :-(
I dont't know why.
I putted MessageBox in this event and never appear.
Your attached example working. I tried to understand the difference but I don't see.
Please look for my grid definition attached in first post.

Only one difference which I see is:
In my project
            this.ClientGrid.TableDescriptor.AllowEdit = false;
            this.ClientGrid.TableDescriptor.AllowNew = false;
            this.ClientGrid.TableDescriptor.AllowRemove = false;
in your example all values are true.
When I changed it to true it ended with a catastrophe ... all "gridColumnDescriptor*.HeaderText" and "gridColumnDescriptor*.MappingName" in my Form.Designer.cs diappeared (i have 10 grids with lot of columns). Fortunately I had backup.




SN Sindhu Nagarajan Syncfusion Team March 8, 2018 12:44 PM UTC

Hi Krzysztof, 
 
Thanks for the update.  
 
We can reproduce the reported scenario. If you set the AllowEdit property as False, Edit mode in GridGroupingControl is not enabled. So, CheckBoxClick event has not raised. In order to overcome this scenario, CellValue can be set  by using Record.SetValue() method in TableControlCellClick  event. Please make use of the code and sample below, 
 
Code Example 
private void GridGroupingControl1_TableControlCellClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e) 
{ 
     if(e.Inner.RowIndex>2 && e.Inner.ColIndex==2) 
     { 
         var cellValue = e.TableControl.Table.CurrentRecord.GetValue("Checkbox"); 
         if (cellValue.ToString() == "1") 
             e.TableControl.Table.CurrentRecord.SetValue("Checkbox", 0); 
         else 
             e.TableControl.Table.CurrentRecord.SetValue("Checkbox", 1); 
     } 
} 
 
 
Please let us know if you have other queries. 
 
Regards,  
Sindhu 
 



KA Krzysztof Adamowicz March 8, 2018 07:49 PM UTC

Working.
Thanx for your help


SN Sindhu Nagarajan Syncfusion Team March 9, 2018 10:25 AM UTC

Hi Krzysztof,  
 
Thanks for your update. 
 
We are glad to hear that the provided solution resolved your scenario. Please let us know if you have any other queries. 
 
Regards, 
Sindhu  


Loader.
Up arrow icon