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

Dynamically Add Column?

2 Answers 247 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 12 May 2014, 08:17 AM
I have a RadGrid with child DetailsTables bound to Entity Data sources. This all works.

How do I add dynamically add a column to, say, a second-level Data Table, which gets the "MAX" value for the third-level Data Table.

For example:

 - Job Type 
  - Job  <--- [I need to show the Wage for the current Effective Date here]
     - Effective Date(s) + Wage

I figure I'll need to do this dynamically, as it's too tricky to determine the current effective date, e.g. (now <= Effective Date).First() . 

Anyway, not sure if I do this in ItemCreated for the OwnerTableView of the DetailsTable or in a higher-up event.

Thanks.

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 15 May 2014, 07:54 AM
Hello Peter,

Adding column into the ItemCreted event is not supported. The RadGrid columns can be added programmatically only into the PageInit event (when the RadGrid is created entirely into the code behind) and on PageLoad (when the RadGrid is partially declared into the markup). More information you can find into the following online documentation article:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html
If you need to change columns based on some condition I suggest you to add all columns initially and hide/show some of them by setting their Visible property to false/true. More information you can fine here:
http://www.telerik.com/help/aspnet-ajax/grid-using-columns.html (Visibility and rendering of columns section)

I hope this help.

Regards,
Radoslav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Peter
Top achievements
Rank 1
answered on 22 May 2014, 02:09 AM
Yes thank I did that. 

Another handy thing I found is that if I handle the Selected event of an EntityDataSource, I can harvest out current/parent collections and use it in my calculations during ItemDataBound.

e.g.

protected void edsWageIncrease_Selected(object sender, EntityDataSourceSelectedEventArgs e)
        {
            List<WageIncrease> agreementWageIncreases = e.Results.Cast<WageIncrease>().ToList();
            ....
}
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Peter
Top achievements
Rank 1
Share this question
or