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

Customizing Rowheader

How to customize row header.
I tried giving doing this
if (e.Cell.ColumnIndex == 0 &&
e.Cell.RowIndex != 0 &&
e.Cell.RowIndex != (gridDataControl1.Model.RowCount - 1))
{
e.Style.CellValue = e.Cell.RowIndex;
e.Style.CellType = "DataBoundTemplate";


e.Style.CellItemTemplateKey = RowHeaderTemplateKey";

}

how ever after is sort or select a row template effects are gone.

please advise.

thanks



3 Replies

RA Rajasekar Syncfusion Team October 14, 2011 01:51 PM UTC

Hi Mrudang,

Thanks for your update, You can able to prevent this behavior by setting those properties in PrepareRenderCell event instead QueryCellInfo event like below,

Code Snippet[C#]

this.dataGrid.ShowAddNewRow = false;
this.dataGrid.ShowRowHeader = true;
this.dataGrid.ModelLoaded += new EventHandler(dataGrid_ModelLoaded);

void dataGrid_ModelLoaded(object sender, EventArgs e)
{
this.dataGrid.Model.Grid.PrepareRenderCell += new Syncfusion.Windows.Controls.Grid.GridPrepareRenderCellEventHandler(Grid_PrepareRenderCell);
}

void Grid_PrepareRenderCell(object sender, Syncfusion.Windows.Controls.Grid.GridPrepareRenderCellEventArgs e)
{
if (e.Cell.ColumnIndex == 0 && e.Cell.RowIndex > 0)
{
e.Style.CellValue = e.Cell.RowIndex;
e.Style.CellType = "DataBoundTemplate";
e.Style.CellItemTemplateKey = "rowHeaderTemplate";
}
}

Please find the sample in the below location,

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

Please let us know if you have any queries.

Thanks,
Rajasekar




MM Mrudang Majmudar October 14, 2011 11:59 PM UTC

Thanks Rajasekar for reply.

now my template changes sticks.
but have different issue.

row header is of fixed size .
It does not grow based on the value of cell.

if row index > 4 digits or so it gets clipped.





RA Rajasekar Syncfusion Team January 6, 2012 01:32 PM UTC

Hi Mrudang,

Sorry for the delay in getting back to you.

You can achieve this requirement by using the below code snippet,

this.dataGrid.ModelLoaded += new EventHandler(dataGrid_ModelLoaded);

void dataGrid_ModelLoaded(object sender, EventArgs e)
{
this.dataGrid.Model.ResizeColumnsToFit(GridRangeInfo.Table(), GridResizeToFitOptions.None);
}

Please find the modified sample in the below location,

Modified Sample:

http://www.syncfusion.com/downloads/Support/DirectTrac/88940/SyncWPFRowHeaderTemplate-1057648007.zip

Please let us know if you have any queries.

Thanks,
Rajasekar



Loader.
Live Chat Icon For mobile
Up arrow icon