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

Grid Cell bound to multiple DataTables

Hi, I have a usercontrol that I am showing in a column of my grid. The user controls displays information from 2 tables. The usercontrol and the gridcell seem to be exchnaging values via CellValue. The question is: 1)For the table cell, how do I distinguish between the 2tables. i.e. if I set a CellValue=2, how can I distinguish which table that cell is referring to? Thanks!

3 Replies

AD Administrator Syncfusion Team August 24, 2004 06:20 PM UTC

Are you setting gridBoundColumn.StyleInfo.CellType = "Control" for the column. If so, this will not work. With th e"Control" celltype, you cannot use the cell control in more than one cell. The reason is that there is no way to for the single control to handle values from multiple cells. To share a cell control among several cells, you have to derive a CellModel class and a CellRenderer class. You can see samples in the grid\samples\celltypes\monthcalendar and in the cellttype\slider samples that we ship. (There are also many other samples that use derived cell controls. Do a search for CellModels.Add in the grid\samples folder to see them all.) If this is not what you need, can you explain a little more about what you are doing?


MB Madhavi Balusu August 24, 2004 06:38 PM UTC

Hi Clay, I am deriving from CellModel and CellRenderer. This is what I have right now: this.expenseGrid.Model.CellModels.Add("MyCtlModel", new MyCtlModel(this.expenseGrid.Model)); this.colService.StyleInfo.CellType = "MyCtlModel"; MyCtlModel instantiates my usercontrol. This usercontrol show data from 2 tables. Imagine I want to set my grid''s style.CellValue=2 from the usercontrol, but this ''2'' is the value from 2nd table and not 1st. How do I let the grid''s cell know that? That it has to display the DisplayMember of the 2nd table and not 1st? Thanks!


AD Administrator Syncfusion Team August 24, 2004 07:20 PM UTC

If you want to assign the value 2 to the grid at the cell which is active from within the renderer class, you can try this.Grid.Model[this.RowIndex, this.ColIndex].CellValue = 2;. The grid would not care whether the value 2 came from one table or the other. Normally, you override renderer.OnSaveChanges to save the value from the control in the renderer to the Grid. Here is what the GridCellRendererBase.OnSaveChanges looks like.
protected virtual bool OnSaveChanges()
{
	TraceUtil.TraceCurrentMethodInfoIf(Switches.CellRenderer.TraceVerbose, this.ControlText);
	if (CurrentCell.IsModified)
	{
		Grid.Model[currentRowIndex, currentColIndex].FormattedText = this.ControlText;
		return true;
	}
	return false;
}

Loader.
Live Chat Icon For mobile
Up arrow icon