This is a migrated thread and some comments may be shown as answers.

ItemDataBound and Column Grouping

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin Horst
Top achievements
Rank 1
Martin Horst asked on 22 Feb 2017, 10:05 AM

Hi,

in my web application I data bind a list of simple POCO objects into the grid. In the ItemDataBound event handler I add some additional columns with generated values.

E.g.:

protected void radGridResult_ItemDataBound(object sender, GridItemEventArgs e)
{
  GridDataItem lGridDataItem = e.Item as GridDataItem;
 
  if ( lGridDataItem != null )
  {       
    lGridDataItem["Address"].Text = "Foobar";
  }
}

 

This works fine unless I try to group the "Address" column inside the web application. Then I get an exception that the "Address" property cannot be found inside the data object. 

Is there a way to solve this problem or is it better to create a new POCO data object containing all neccessary properties instead.

 

Best regards

Martin Horst

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 27 Feb 2017, 06:59 AM
Hi Martin,

Database related operations like filtering, sorting, grouping, etc. require the values to be present in a field in the grid's data source. It is not possible to apply these actions with hardcoded values. Therefore, the Address on your case should be present in the database which the grid is bound to:
http://www.telerik.com/forums/sorting-unbound-column-onneeddatasource#NFYQrrz76UO-rJgUqK7gUA

Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Martin Horst
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or