Query |
Response |
I have tries to create a MasterDetail record on the same table that the control is linked to but the related table and the design view shows the same table as the related table. But when I run the form and open up the related table there are no related records. My data is setup with some relations that should show a child record for some of the parent records |
To create a child table for same table, you could prepare the separate table to create the relation between that two tables. Please refer the following code example.
C#
DataTable parentTable = CreateTable();
DataTable child = CreatedchildTable();
child.TableName = "ParetToChild";
GridRelationDescriptor relation = new GridRelationDescriptor();
relation.ChildTableName = "Relation";
relation.RelationKind = Syncfusion.Grouping.RelationKind.RelatedMasterDetails;
relation.RelationKeys.Add("Id", "ParentId");
this.gridGroupingControl1.TableDescriptor.Relations.Add(relation);
this.gridGroupingControl1.SourceListSet.Add("Parent", parentTable);
this.gridGroupingControl1.SourceListSet.Add("Relation", child);
this.gridGroupingControl1.DataSource = parentTable; |
how can I remove the "+" symbol if the master record does |
To hide the caption plus/minus cell, you could set the CellType as Static for RecordPluseMinusCell in QueryCellStyleInfo event. Please refer the following code example.
C#
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordPlusMinusCell)
{
Element cell = e.TableCellIdentity.DisplayElement;
Record r = cell.ParentRecord as Record;
bool makeStatic = true;
if (r != null && r.NestedTables.Count > 0)
{
foreach (NestedTable nt in r.NestedTables)
{
if (nt.ChildTable.GetFilteredRecordCount() != 0)
makeStatic = false;
}
}
if (makeStatic)
{
e.Style.CellType = "Static";
e.Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(208, 215, 229));
}
}
}
|