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

DataTemplate Column in GridDataControl

I have followed your example for setting a datatemplate in a column of the grid.

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e) {
if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex == 5) {
e.Style.CellType = "DataTemplate";
//e.Style.CellTemplateKey = "editableEmployee";
//e.Style.CellValue = employeesSource.Employees[e.Cell.RowIndex % employeesSource.Employees.Count];
//e.Style.Background = Brushes.Linen;

}
}

This works fine, except when the user changes the position of the columns. How do we resolve that issue?

I think a more elegant solution (for future grids) might be something like this.





5 Replies

DB David Brenchley March 2, 2010 06:14 PM UTC

The solution I have come up with is the following.

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e) {
if (e.Cell.ColumnIndex > 0 && e.Cell.RowIndex > 0
&& TicketGrid.VisibleColumns[e.Cell.ColumnIndex - 1].MappingName == "AssignedUsers"
) {
e.Style.CellType = "DataTemplate";
}
}


GK Ganesan K Syncfusion Team March 3, 2010 09:40 AM UTC

Hi David,

Thanks for using Syncfusion products.

You can use the following code to achieve your requirement







Please let us know if you need any more details.

Thanks
Ganesan


DB David Brenchley March 4, 2010 04:38 PM UTC

Ah, I like it. Nice and clean.

Thank you very much.


DB David Brenchley March 4, 2010 09:26 PM UTC

This code does not work. It just shows is:

CellType = "DataTemplate" CellValue=








If it helps, here is my datatemplate















Text="{Binding UserName}"/>











GK Ganesan K Syncfusion Team March 17, 2010 09:00 PM UTC

Hi David,

Thanks for the update,

The following sample illustrates the use of data-bound templates with the Grid Data Control. Could you please verify?

http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=CS2415316.zip

Please let us know if you need any more details.

Thanks
Ganesan

Loader.
Live Chat Icon For mobile
Up arrow icon