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

TableModel of child table

Hi,
Is there any way to access the tablemodel of a child table in a grid grouping control?

I can access the child table using:
ChildTable itemAttribTable = gridGroupingControl1.Table.Records[0].NestedTables[0].ChildTable;

But the child table doesn't seem to have a table model.

Thanks


3 Replies

AD Administrator Syncfusion Team June 24, 2008 11:08 PM UTC

Try this code to see if this gives you what you want:

ChildTable itemAttribTable = gridGroupingControl1.Table.Records[0].NestedTables[0].ChildTable;
GridTableModel model = gridGroupingControl1.GetTableModel(itemAttribTable.Name);




AD Administrator Syncfusion Team June 25, 2008 04:46 PM UTC



>Try this code to see if this gives you what you want:

ChildTable itemAttribTable = gridGroupingControl1.Table.Records[0].NestedTables[0].ChildTable;
GridTableModel model = gridGroupingControl1.GetTableModel(itemAttribTable.Name);




Thanks for the reply,

The code gives me the tableModel, but it seems to contain rows for the entire table, not just the rows in the table grouped under the child table for that record.

Is there any way to get a tableModel that only contains rows for the child table of a specific record? (the rows displayed grouped under the record)

What I'm really trying to do is find a way to index straight to the cell properties of a cell in a child table (cellStyle, text, dropdown datasource) outside of an event.



AD Administrator Syncfusion Team June 26, 2008 02:26 PM UTC

If you know the gridrecord and fieldname of a cell in a grid with nested tables, then you can get the style using code like:

private GridTableCellStyleInfo GetStyleFromRecordColumn(GridRecord record, string column)
{
GridTableCellStyleInfo style = null;

GridTable table = (GridTable)record.ParentTable;
if (table != null)
{
GridTableDescriptor td = table.TableDescriptor;
GridTable childTable = table;// gridGroupingControl1.GetTable(name);

//now get the proper row index wrt to nested tables
ChildTable ct = table.FilteredChildTable; //save the childtable
//get the correct column index wrt nested tables
int field = td.NameToField(column);
int colIndex = td.FieldToColIndex(field);

table.FilteredChildTable = record.ParentChildTable;
int rowIndex = table.DisplayElements.IndexOf(record); //look up index in the right table
style = table.GetTableCellStyle(rowIndex, colIndex);
table.FilteredChildTable = ct; //reset the childtable
}

return style;
}



Loader.
Live Chat Icon For mobile
Up arrow icon