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.
Unfortunately, activation email could not send to your email. Please try again.

Checkbox row selection in gridgroupingcontrol, continually adding rows.

Thread ID:

Created:

Updated:

Platform:

Replies:

124160 May 21,2016 09:13 PM May 25,2016 10:42 AM Windows Forms 5
loading
Tags: GridGroupingControl
James
Asked On May 21, 2016 09:13 PM

Hi,

I've been running into an error when trying to do checkbox row selection with the gridgroupingcontrol.

I've based my code off of thishttp://www.syncfusion.com/forums/105749/Check-box-for-row-selection-in-grid-grouping-control

While this works when the datatable is not changing when I am adding rows to the datatable the checkbox selection is incorrect, sometimes the checkboxes get unchecked or moved.

I will attach a video showing the offending behaviour. (Sorry the video goes on about 20 seconds too long )

I have also attached some code showing you how rows is added and how i'm handling checkboxes

(dmTable is a DataTable)

//partial code
{..
this.gridGroupingControl1.DataSource = this.dmTable;
//Disallow Editing
this.gridGroupingControl1.ActivateCurrentCellBehavior = GridCellActivateAction.None;
this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
#region Checkbox Settings
this.gridGroupingControl1.TableControlCheckBoxClick += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);
#endregion
..}
{..
System.Data.DataRow row = this.dmTable.NewRow();
row[COL_SDE] = sde;
row["Select"] = checkBoxValue[1];
row[COL_Imported] = string.Empty;
row[COL_Date] = sde.GetDate();
foreach (string seriesName in seriesNames)
{
row[seriesName] = sde.GetValue(seriesName);
}
// add row to the table
this.dmTable.Rows.InsertAt(row, 0);

...}

void gridGroupingControl1_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)
{
Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfo style = (Syncfusion.Windows.Forms.Grid.Grouping.GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);
Record currentRecord = style.TableCellIdentity.DisplayElement.GetRecord();
// Selection added for current record
if (this.gridGroupingControl1.TableModel[e.Inner.RowIndex, e.Inner.ColIndex].Text == "False")
currentRecord.SetSelected(style.Text == "False");
}
anyway wondering if i'm doing something wrong or if syncfusion can not handle it.

Attachment: Syncfusionvideo_83efcf81.zip

Adhikesevan Kothandaraman [Syncfusion]
Replied On May 23, 2016 06:31 AM

Hi James, 

Thanks for using Syncfusion products. 

To Set the record based on the selection on the check box column, Change the conditions given in the TableControlCheckBoxClick event as of follows, 

Code Snippet: 
this.gridGroupingControl1.TableControlCheckBoxClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick); 
void gridGroupingControl1_TableControlCheckBoxClick(object sender, GridTableControlCellClickEventArgs e) 
{ 
    GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex); 
    Record currentRecord = style.TableCellIdentity.DisplayElement.GetRecord(); 
    currentRecord.SetSelected(style.Text == "False"); 
} 
  
Sample Link: 
 
Regards, 
Adhi  


James
Replied On May 23, 2016 08:18 AM

I'm still running into an error like in the video, either the checkbox is moving or it's selecting something i'm not selecting, i'll upload another video.


Also the link you sent me also doesnt continually add rows like my version. Anyway you could get a version to continually add rows? Or can syncfusion not handle it, and the checkbox selection.




Attachment: syncvideo2_be2f6307.zip

Adhikesevan Kothandaraman [Syncfusion]
Replied On May 24, 2016 11:08 AM

Hi James, 

Thanks for your update. 

We have tried to replicate the scenario with adding more number of rows in with the check box selection. Since the selection is made on the row index, the added row index collapses the selection.  
As a suggestion use the condition in the QueryCellInfo instead of the TableControCheckBoxClick event.  

Regards, 
Adhi 


James
Replied On May 24, 2016 03:47 PM

Hey, 

Is there any examples doing something like this?, new to this controller.
Should I be using QueryCellInfo, or QueryCellStyleInfo?

Thank you,

James

Adhikesevan Kothandaraman [Syncfusion]
Replied On May 25, 2016 10:42 AM

Hi James, 

Regret for the inconvenience caused. 

The reported scenario can be achieved by using QueryCellStyleInfo event with certain limitation. The selection can be added based on the checkbox value only on the grid is in static mode.  
When adding the new rows, you can select the checkbox values. The grid will update selected records at the end of the update. Please refer to the following code snippet, 

Code Snippet: 
 
//Set to true only on adding the new rows 
bool updating = false; 
this.gridGroupingControl1.QueryCellStyleInfo += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo); 
 
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if(e.Style.CellType == GridCellTypeName.CheckBox && !updating ) 
    { 
        e.Style.TableCellIdentity.DisplayElement.GetRecord().SetSelected(e.Style.Text == "True"); 
    }             
} 
 
Sample Link: 

Regards, 
Adhi 


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.

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.

;