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

how to allow user to select only parent record

how to allow user to select only parent record and not select child records

9 Replies

AD Administrator Syncfusion Team February 6, 2007 05:26 PM UTC

Hi Gkrish,

One way you can do this by handling the SelectedRecordChnaging event of the grid and set e.Cancel to true for inner most child table(child records). Here is a code snippet.

this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridGroupingControl1.SelectedRecordsChanging +=new SelectedRecordsChangedEventHandler(gridGroupingControl1_SelectedRecordsChanging);

private void gridGroupingControl1_SelectedRecordsChanging(object sender, SelectedRecordsChangedEventArgs e)
{
if( e.Action == SelectedRecordsChangedType.Added )
{
if( e.SelectedRecord != null && e.SelectedRecord.Record.NestedTables.Count == 0 )
e.Cancel = true;
}
}

Please refer to the attached sample for implementation.
Excel Export.zip

Best Regards,
Haneef


GK Geetha Krishnamurthy February 7, 2007 10:30 PM UTC

thank you


GK Geetha Krishnamurthy February 8, 2007 03:24 PM UTC

this one doesnt work like explained or expected.. the code snippet has no effect...


AD Administrator Syncfusion Team February 9, 2007 01:47 AM UTC

Hi Gkrish,

We were not able to reproduce the issue here. Is it possible for you to upload us a sample or modify the attached samples to reproduce the issue here? This will help us to analyse the issue further.

Here is a sample.
Excel Export.zip

Best regards,
Haneef


GK gkrish February 9, 2007 04:17 PM UTC

attached is the sample...

Excel Export_1872b9530.zip


GK Geetha Krishnamurthy February 15, 2007 06:55 PM UTC

I have attached a sample in my previous posting where you can it doesnt work as expected. Kindly look into it and let me know what is the problem.

thank you


AD Administrator Syncfusion Team February 15, 2007 11:15 PM UTC

Hi Gkrish,

The reason for getting this problem is that you are enabled the cell based ( derived from GridControlBase) selection type in a grouping grid. You can turn of the cell based selection using TableOptions.AllowSelection property to None. Andthen enable the record based selection in a grid using ListBoxSelectionMode property. Here is a code snippet.

this.gridGroupingControl1.TableOptions.AllowSelection = GridSelectionFlags.None;
this.gridGroupingControl1.TableOptions.ListBoxSelectionMode = SelectionMode.MultiExtended;
this.gridGroupingControl1.SelectedRecordsChanging +=new Syncfusion.Grouping.SelectedRecordsChangedEventHandler(gridGroupingControl1_SelectedRecordsChanging);
this.gridGroupingControl1.Table.ExpandAllRecords();

Here is a modified sample.
modifiedExcel Export.zip

Here is KB article that discuss about the groupgrid selection selection types.
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=344

Best regards,
Haneef


GK Geetha Krishnamurthy February 16, 2007 04:01 PM UTC

if i dont set allowselection to row, i will not be able to hit delete key placing the selction on a parent record. Rather if I hit delete it does nothing. if i do set to allowselection to row, it deletes that row from the grid and associated dataset. So i think I will need that to remain row or please let me know if there is another way i can hit delete to delete row...


AD Administrator Syncfusion Team February 16, 2007 09:19 PM UTC

Hi Gkrish,

Please refer to the forum thread and let me know if this helps.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=45230

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon