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

[Solved] Refresh parent record only when nested item changed

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Mikla
Top achievements
Rank 1
Jeff Mikla asked on 29 Jan 2010, 10:53 PM
I've got a requirement to allow the user to track the forecast revenue for a project.
I had initially designed this with a nested grid.  The parent grid had the basic project attributes as well as the total forecast for the project.
When you expand the record it would display the specific forecast items by month and year.  The user could then add/edit/delete forecast items.  What I've found is that I need the parent record to be refreshed when a forecast item has been added/modified so that the forecast total is accurately represented in the parent record.
I can't seem to figure out a way to just refresh the parent record.

Any help would be appreciated.
Brian VZ

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Feb 2010, 12:34 PM
Hello Brian,

I tried the following code in order to update t he parent table value in grid upon updating/inserting values in details table.

CS:
 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.PerformInsertCommandName || e.CommandName == RadGrid.UpdateCommandName) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            GridDataItem parentItem = (GridDataItem)(((Telerik.Web.UI.GridNestedViewItem)(item.Parent.NamingContainer.NamingContainer))).ParentItem; // Getting access to parent item            
            parentItem["CompanyName"].Text = "Value"// Set the value 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Jeff Mikla
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or