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

How to implement a scene like the "NestedSummary2005" sample using GridGroupingControl

I have a self-referential table with "ID","NAME","COST" and "FID" fields.The self-referential level isn't constant.The data_relation is between "ID" and "FID" fields.
1.How to make "ID","NAME","COST" columns as same width using TrackWidthOfParentColumn property in a loop code?
2.When a record at level n gets a child table and its "COST" field value changed event raises,how to set "COST" field value at level n-1 table as sum of "COST" field value at level n table,"COST" field value at level n-2 table as sum of "COST" field value at level n-1 table...so on.
3.When a record gets a child table,how to make it "readonly".

Regards,
LaoXu


2 Replies

AD Administrator Syncfusion Team March 17, 2008 03:12 PM UTC

Hi Laoxu,

we are working on the forum.. we will update you soon.. Thanks for your interest in syncfusion products..

regards,
Janagan



AD Administrator Syncfusion Team March 27, 2008 03:05 PM UTC

Hi laxou,

Issue 1: TrackWidthOfParentColumn
>>>>>>>>>>

You can use the below code snippet to resolve this issue.

private void SetTrackWidthOfParentColumn( GridTableDescriptor descriptor)
{
if (descriptor == null) return;

foreach (GridRelationDescriptor relationDescriptor in descriptor.Relations)
{
for (int n = 0; n < relationDescriptor.ChildTableDescriptor.VisibleColumns.Count ; n++)
{
relationDescriptor.ChildTableDescriptor.Columns[n].ResetTrackWidthOfParentColumn();
relationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = relationDescriptor.ParentTableDescriptor.Columns[n].Name;
}
SetTrackWidthOfParentColumn(relationDescriptor.ChildTableDescriptor);
}
}

For call the above method, please use this

SetTrackWidthOfParentColumn(this.gridGroupingControl1.TableDescriptor);

Issue 2: Sumarry
>>>>>>>>>

You need to add the SummaryRowDescriptor for each self relation table in a GroupingGrid. Below are the codes that shows you "How to add the Count summary for SelfRelation table in GroupingGrid?".

private GridRelationDescriptor AddManualRelations( GridTableDescriptor parentgridTableDescriptor )
{
GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor( );
parentToChildRelationDescriptor.ChildTableName = "SelfReferencingTable"; // same as SourceListSetEntry.Name for childTable (see below)
parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;
parentToChildRelationDescriptor.RelationKeys.Add( "DEPTNO", "ADMRDEBT" );

// Add relation to ParentTable
parentgridTableDescriptor.Relations.Add( parentToChildRelationDescriptor );
parentgridTableDescriptor.AllowNew = false;
parentgridTableDescriptor.AllowEdit = false;
GridSummaryColumnDescriptor totalSum = new GridSummaryColumnDescriptor("CumBuyQty");
totalSum.SummaryType = SummaryType.Count;
totalSum.Style = GridSummaryStyle.Column;
totalSum.DataMember = "DEPTNO";
totalSum.DisplayColumn = "DEPTNO";
totalSum.Format = "{Count:#}";

GridSummaryRowDescriptor sRow = new GridSummaryRowDescriptor("Totals", totalSum);
parentToChildRelationDescriptor.ChildTableDescriptor.SummaryRows.Add(sRow);
return parentToChildRelationDescriptor;
}

Issue 3: ReadOnly
>>>>>>>>>>

You need to set the AllowEdit property of the TableDescriptor to true. Below are the codes:

parentgridTableDescriptor.Relations.Add( parentToChildRelationDescriptor );
parentgridTableDescriptor.AllowNew = false;
parentgridTableDescriptor.AllowEdit = false;

//OR

You can handle the CurrentCellStartingEditing event of the GroupingGrid and set the e.Inner.Cancel to TRUE for all parentable.

Please refer to the attached sample for implementation and let me know if this helps.
http://websamples.syncfusion.com/samples/ModifiedSelfRelations.zip


Best regards,
Haneef



Loader.
Live Chat Icon For mobile
Up arrow icon