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 can i place a sub-columns inside a datatable column???

I wanted to place a column (days) in my datatable with many sub-columns inside it. Each of this sub-columns will have a different day with different data inside. Any idea how to place a column inside other???


3 Replies

JS Jeba S Syncfusion Team January 23, 2008 11:52 AM UTC

Hi Daniel,

Sorry for the delay in response.

You need to use the custom cell type for storing the different value in a single cell. It requires a model class and a renderer
class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer
class handles the UI requirements of the cell. Then to use the custom cell type in a grid, you need to register this celltype
with the grid. Below is the code snippets:

this.gridGroupingControl1.TableModel.CellModels.Add("TwoTextBoxCell", new TwoTextBoxCellModel(this.gridGroupingControl1.TableModel));
this.gridGroupingControl1.TableDescriptor.Columns["Customers"].Appearance.AnyRecordFieldCell.CellType = "TwoTextBoxCell";


Please refer this sample that implements the split column cell type.
http://websamples.syncfusion.com/samples/Grid.Windows/F71098/main.htm

It implements the GridGenericControlCellModel and GridGenericControlCellRenderer for creating a custom cell type in a grid.

Kindly let us know if you need any further assistance.

Best Regards,
Jeba.







DS Daniel Santos de Carvalho January 25, 2008 07:01 PM UTC

Actually, i'm looking for something that allow the "colspan" effect of the html in the header.

There is a way to put a text that take the header space of many columns??



JS Jeba S Syncfusion Team January 28, 2008 07:27 AM UTC

Hi Daniel,

Thank you for your update.

You can achieve the column spanning of header by handling the QueryCoveredRange event. Here is the code snippet that shows merging a range of columns using QueryCoveredRange event.


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
int col1 = 3,col2 = 4;
private void gridGroupingControl1_QueryCoveredRange(object sender, GridTableQueryCoveredRangeEventArgs e)
{
GridTable thisTable = this.gridGroupingControl1.Table;
if (e.RowIndex < thisTable.DisplayElements.Count)
{
Element el = thisTable.DisplayElements[e.RowIndex];
if(el.Kind == DisplayElementKind.ColumnHeader)//.Record)
{
if(e.ColIndex >= col1 && e.ColIndex <= col2)
{
e.Range = GridRangeInfo.Cells(e.RowIndex, col1, e.RowIndex, col2);
e.Handled = true;
}
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Please refer to the attached sample that illustrates the same:
http://websamples.syncfusion.com/samples/Grid.Windows/F71098New/main.htm

Kindly let us know if you need any further assistance.

Best regards,
Jeba.



Loader.
Live Chat Icon For mobile
Up arrow icon