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

Accessing the parent item on _RowDrop()

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 06 Mar 2009, 09:15 PM
I have a RadGrid with a nested table, as outlined below:

<telerik:RadGrid ID="grid1" Skin="Default" runat="server" Visible="False" AutoGenerateColumns="False" 
    ShowHeader="False" Width="400px" OnItemDataBound="grid1_ItemDataBound" AllowMultiRowSelection="True" 
    OnRowDrop="grid1_RowDrop" OnDeleteCommand="grid1_DeleteCommand" OnPreRender="grid1_PreRender"
    <MasterTableView DataKeyNames="AnswerID"
    <DetailTables>  
        <telerik:GridTableView Name="grid2">         
            <Columns> 
            <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" DataField="AnswerLabel" 
                ReadOnly="True" Reorderable="False" Resizable="False" ShowSortIcon="False" UniqueName="colAnswerLabel"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="QuestionID" UniqueName="colQuestionID" Visible="False"
            </telerik:GridBoundColumn> 
            <telerik:GridBoundColumn DataField="AnswerID" UniqueName="colAnswerID" Visible="False"
            </telerik:GridBoundColumn> 
            </Columns> 
            <RowIndicatorColumn> 
            <HeaderStyle Width="20px" /> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
            <HeaderStyle Width="20px" /> 
            </ExpandCollapseColumn> 
        </telerik:GridTableView>  
    </DetailTables> 
    <Columns> 
        <telerik:GridBoundColumn AllowFiltering="False" AllowSorting="False" DataField="AnswerLabel" 
        ReadOnly="True" Reorderable="False" Resizable="False" ShowSortIcon="False" UniqueName="colAnswerLabel"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="QuestionID" UniqueName="colQuestionID" Visible="False"
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn DataField="AnswerID" UniqueName="colAnswerID" Visible="False"
        </telerik:GridBoundColumn> 
    </Columns> 
    <RowIndicatorColumn> 
        <HeaderStyle Width="20px" /> 
    </RowIndicatorColumn> 
    <ExpandCollapseColumn> 
        <HeaderStyle Width="20px" /> 
    </ExpandCollapseColumn> 
    </MasterTableView> 
    <ClientSettings AllowRowsDragDrop="True"
    <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
</telerik:RadGrid> 

Is there a way to access the colAnswerID column of the parent row from within grid1_RowDrop(object sender, GridDragDropEventArgs e)

For example, if I'm dragging "222" between "111" and "333" I'd want the colAnswerID for "ABC".

 +ABC 
 |- 111 
 |- 333 
 |- 444 
 +DEF 
 |- 555 
 GHI 
 222 

Thanks.
- Paul Ott

3 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 09 Mar 2009, 05:50 PM
I still can't figure this out.
0
Sebastian
Telerik team
answered on 10 Mar 2009, 11:56 AM
Hello Paul,

Consider referencing the e.DestinationTableView object from within the OnRowDrop server-side handler of the grid which points to the destination table in which the dragged item has been dropped (see the description of this demo for more details).

Then you can reference the ParentItem for this destination table (which will be the parent data item) and extract its AnswerID value either using the getDataKeyValue("AnswerID") method or referencing the value from colAnswerID column using its unique name.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul
Top achievements
Rank 1
answered on 11 Mar 2009, 03:36 PM
Sebastian,

I've tried this, but unfortunately the e.DestinationTableView.ParentItem is null in the RowDrop. After some messing around with it, I found the solution to be:

e.DestDataItem.OwnerTableView.ParentItem.GetDataKeyValue("AnswerId")

Thanks for the help!
- Paul
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or