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
close icon

GroupingGrid and related tables

Hi, I have two questions.

1. How can I deny editing, deleting, adding records in related tables
2. How can I deny drawing related table if that table don''t contain any records.

Please look at attached pictures.

Pictures.zip

2 Replies

AD Administrator Syncfusion Team August 3, 2006 07:11 AM UTC

Hi Sergiy,

You can hide the related table that does not contain any records using the QueryCellStyleInfo event of the gridGroupingControl. Here is some code snippet, that prevents the +/- minus for an empty child table.

if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordPlusMinusCell)
{
Record r = e.TableCellIdentity.DisplayElement.ParentRecord as Record;
if (r != null && r.NestedTables.Count > 0 && r.NestedTables[0].ChildTable.GetFilteredRecordCount() == 0)
{
e.Style.CellType = "Static";
}
}

To avoid editing the records in the related tables, the TableControlCurrentCellStartEditing event can be handled and set e.Inner.Cancel to true. Try the below piece of code.

// TableControlCurrentCellStartEditing event handler
Element el = this.gridGroupingControl1.Table.CurrentElement;
if(el != null && el.Kind == DisplayElementKind.NestedTable)
{
e.Inner.Cancel = true;
}

To avoid deleting any records, set e.Cancel to true in the RecordDeleting event of the corresponding TableDescriptor.

GridTableDescriptor child_tabledescriptor1 = this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor;
child_tabledescriptor1.RecordDeleting += new RecordEventHandler(child_tabledescriptor1_RecordDeleting);

private void child_tabledescriptor1_RecordDeleting(object sender, RecordEventArgs e)
{
e.Cancel = true;
}
Here is a sample
GGC_Nested.zip

Let me know if you need any further assistance.
Thanks,
Rajagopal


AS Asidagk August 3, 2006 02:28 PM UTC

Hi,

Thanx alot. That was helpful.
Finally, i disabled editing and deleting in this way..

foreach (GridRelationDescriptor var in this.gridGroupingControl1.TableDescriptor.Relations)
{
var.ChildTableDescriptor.AllowRemove = false;
var.ChildTableDescriptor.AllowNew = false;
var.ChildTableDescriptor.AllowEdit = false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon