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. Image for the cookie policy date

Selection after Sorting is unstable

Hi,

I have implemented GridGroupingControl. 

my first column is holding checkboxes to select rows. This selection of rows works properly but when i sort the header and try selecting, rows moves up and down and also selection does not happen properly. 

Any help will be highly appreciated.

Thanks,
Tanmaya

3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team October 17, 2014 04:15 AM UTC

Hi Tanmaya,

Thank you for your interest in Syncfusion products.

If you want to select the checkbox and sort the record based on order, you can use the “TableControlCheckBoxClick” event. By this event, you can set the “GetRecord” method. Please refer the below code,

Code:

this.gridGroupingControl1.TableControlCheckBoxClick += new Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCheckBoxClick);

void gridGroupingControl1_TableControlCheckBoxClick(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlCellClickEventArgs e)

        {

            GridTableCellStyleInfo style = (GridTableCellStyleInfo)e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex, e.Inner.ColIndex);

            Record r = style.TableCellIdentity.DisplayElement.GetRecord();

            int index = e.TableControl.Table.DisplayElements.IndexOf(r);

            this.gridGroupingControl1.TableControl.CurrentCell.EndEdit();

            string val = r.GetValue("Add Item").ToString();

        }

Please let us know if you have any concern.

Regards,

Muthukumar K


Attachment: Sorting_9c4d421e.zip


TM Tanmaya Mohanty November 12, 2014 10:53 AM UTC

Hi,

Thanks for your suggestion. unfortunately it does not resolve my issue. This seems to be a syncfusion issue. when the checkbox column is sorted and then you try selecting randomly it does not select the proper item which you intend to select.

I tried with a different approach with custom sorting for the column. Using custom sorting i could sort the particualr column, but coresponding other columns are not getting sorted. I seek your help in this.

Sample code attached.

Thanks,
Tanmaya

Attachment: Sorting_ff082aca.rar


MK Muthukumar Kalyanasundaram Syncfusion Team November 14, 2014 02:21 PM UTC

Hi Tanmaya,

 

Thanks for the update.

 

If you want to sort  particular column you can use ”TableControlQueryAllowSortColumn” event and remaining columns are disabled the sorting operation. We have modified your attached sample. Please refer to it.

 

Code:

 

this.gridGroupingControl1.TableControlQueryAllowSortColumn += new Syncfusion.Windows.Forms.Grid.Grouping.GridQueryAllowSortColumnEventHandler(gridGroupingControl1_TableControlQueryAllowSortColumn);

 

void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e)

  {

   if (e.Column.Name == "Add Item")

     e.AllowSort = true;

   else

                e.AllowSort = false;

  }

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: Sorting_5521fdf2.zip

Loader.
Live Chat Icon For mobile
Up arrow icon