The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I am using Data bound grid. One column is of type DateTime. In certain cases( Time field is Not applicable in certain cases.), I need to display string "N/A" in the cell.
Is there any way to do the same.
I can not make the column of type string and fill it on my own, as I need the sort facility for this column.
Thanks in advance,
Bidin
ADAdministrator Syncfusion Team February 9, 2004 08:26 PM UTC
If you put a special DateTime value (say DateTime.MinValue) in these cells, then you can use these two events to handle this tasks.
this.gridDataBoundGrid1.Model.QueryCellFormattedText += new GridCellTextEventHandler(gridModel_QueryCellFormattedText);
this.gridDataBoundGrid1.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(gridModel_QueryCellInfo);
private void gridModel_QueryCellFormattedText(object sender, GridCellTextEventArgs e)
{
if(e.Value.Equals(DateTime.MinValue))
{
e.Text = "N/A";
e.Handled = true;
}
}
private void gridModel_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if(e.Style.CellType == "MonthCalendar" && e.Style.CellValue.Equals(DateTime.MinValue))
{
e.Style.ReadOnly = true;
e.Style.Clickable = false;
}
}