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.
I have a GDBG with a DataSource.
The DataSource is a collection of objects with properties wich are displayed using the grid MappingName property.
Some of these properties doesn`t return a basic type (string, int, etc.) but another object with properties. These objects have an overriden version of ToString() used to display them in the colums.
What I would like to do, is not to display the ToString() value in the colums but one of the object`s property value. I tryed to use the DisplayMember property of the colum, setting it to the object`s property name, but I still get the ToString()value.
How can I display one of the object`s property instead of the ToString version?
Thank you!
ADAdministrator Syncfusion Team September 25, 2003 06:46 PM UTC
You will have to implement event handlers or overrides for OnDataProviderQueryCellInfo and OnDataProviderSaveCellInfo.
Suppose your dataSource has a TitleInfo object with a Title field and you only want to display the Title string in the column the you could do the following in OnDataProviderQueryCellInfo:
if (e.ColIndex == yourTitleColumnIndex && e.RowIndex > 0)
{
e.CellValue = record.TitleInfo.Tilte;
e.CellValueType = typeof(string);
e.Tag = record.TitleInfo;
e.Handled = true;
}
Setting e.Handled = true will prevent the standard handling of the grid of this column. And the grid will not retrieve the object from your underlying class.
Now, your custom renderer can be a TextBox-derived cell and allow editing of the string. And it also has access to the TitleInfo object through (TitleInfo) style.Tag (in case you need that).
In OnDataProviderSaveCellInfo you can then save back the modified title into the title object, e.g.:
if (e.ColIndex == yourTitleColumnIndex && e.RowIndex > 0)
{
(((TitleInfo) style.Tag).Title = e.Style.Text;
}
Stefan