ItemDataBound and Column Grouping

2 posts, 0 answers
  1. Martin Horst
    Martin Horst avatar
    40 posts
    Member since:
    Apr 2010

    Posted 22 Feb 2017 Link to this post

    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

  2. Eyup
    Admin
    Eyup avatar
    3962 posts

    Posted 27 Feb 2017 Link to this post

    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.
Back to Top