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

[Solved] How to open the inline create/edit form by clicking grid button column

5 Answers 373 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sabarishbabu
Top achievements
Rank 1
sabarishbabu asked on 14 Oct 2009, 01:38 PM
Hi,

Grid(as like cascading grid) has button column.while clicking expend icon, it is displaying detail table records.
If am clicking the button, can we display the inline create form of detail table(inline grid)?


I put the following code for your reference

  <telerik:RadGrid ID="grdAllQuestions"
                                                            AllowPaging="True"
                                                            AllowSorting="False"  
                                                            GridLines="None"  
                                                            runat="server"
                                                            Width="700px"
                                                            Skin="Web20"
                                                            PageSize="4" onitemdatabound="grdAllQuestions_ItemDataBound"
                                                            AutoGenerateColumns="False" onitemcreated="grdAllQuestions_ItemCreated"  
                                                                ondetailtabledatabind="grdAllQuestions_DetailTableDataBind"  OnItemCommand="grdAllQuestions_ItemCommand"
                                                                onneeddatasource="grdAllQuestions_NeedDataSource"  oninsertcommand="grdAllQuestions_InsertCommand"                                                                 
                                                                >
                                                             <MasterTableView ShowHeadersWhenNoRecords="true" NoMasterRecordsText="No records to display"
                                                             Width="700px"   DataKeyNames="TrackerId" TableLayout="Fixed">
                                                             
                                                             <ExpandCollapseColumn HeaderText="Answer"  ExpandImageUrl="../../../../Images/Icons/Plus.png" CollapseImageUrl="../../Images/Icons/Plus.png" Visible="true"></ExpandCollapseColumn>
                                                                <Columns>
                                                               
                                     
                                                                 
                                                             
                                <telerik:GridBoundColumn HeaderText="Asked By" DataField="CreatedBy" UniqueName="CreatedBy" >
                                </telerik:GridBoundColumn>
                                <telerik:GridButtonColumn Text="Answer" UniqueName="Answer"  CommandName="Answer" ButtonType="PushButton">
                                 </telerik:GridButtonColumn>
                               
                                                                    
                                                                 
                                                                </Columns>
                                                                
                                                                 <DetailTables>
                                                                     
                                                                    <telerik:GridTableView    CommandItemDisplay="Top"  Width="100%"
                                                                        runat="server" Name="answers"
                                                                        AutoGenerateColumns="false" DataKeyNames="TrackerDtlId" TableLayout="Fixed">
                                                                        <CommandItemSettings AddNewRecordText="Add new answer" />
                                                           
                                                                       
                                                                        <Columns>
                                                                       
                                                                            
                                                                               <telerik:GridDateTimeColumn HeaderText="Date Answered" HeaderButtonType="TextButton"
                                                                DataField="CreatedDate" UniqueName="CreatedDate">
                                                             </telerik:GridDateTimeColumn>
                                                             
                                <telerik:GridBoundColumn HeaderText="Answered by" DataField="CreatedBy" UniqueName="CreatedBy" >
                                </telerik:GridBoundColumn>
                                                                              
                                                                             
                                                                         
                                                                       </Columns>
                                                                        
                                                                       
                                                                    </telerik:GridTableView>
                                                                 </DetailTables>
                                                               
                                     
                                                            </MasterTableView>
                                                        </telerik:RadGrid>


In this example, Can we open the inline create/edit form for the inner grid by clicking answer button?
answer button is in the master table, i want to show the inline create of childgrid while clicking answer button

Thanks for your  help,

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Oct 2009, 05:24 AM
Hi Sabarishbabu,

Try the following code snippet in order to put the detailtable items in EditMode on clicking the buttonclumn in MasterTableView.

C#:
 
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    if (e.CommandName == "Answer"
    {     
        GridDataItem item = (GridDataItem)e.Item; 
        item.Expanded = true
        GridTableView tableview = (GridTableView)item.ChildItem.NestedTableViews[0]; 
        foreach(GridDataItem childItem in tableview.Items) 
        { 
            childItem.Edit = true
        } 
        RadGrid1.Rebind(); 
    } 

-Shinu.
0
sabarishbabu
Top achievements
Rank 1
answered on 15 Oct 2009, 05:40 AM
thanks a lot.

It is opening the edit form of child table.

i want to open inline create form of child table. Can you tell me?


Thanks
0
sabarishbabu
Top achievements
Rank 1
answered on 15 Oct 2009, 06:04 AM
hi shinu,

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    if (e.CommandName == "Answer"
    {     
        GridDataItem item = (GridDataItem)e.Item; 
        item.Expanded = true
        GridTableView tableview = (GridTableView)item.ChildItem.NestedTableViews[0];
 tableview.IsItemInserted = true;
        RadGrid1.Rebind(); 
    } 

I tried this also, but inline create form is not opening

Thanks
0
Princy
Top achievements
Rank 2
answered on 15 Oct 2009, 06:50 AM
Hello Sabarishbabu,

If you want to display the insert form for the child table on button click, then you would have to call the Rebind method for the child tableview. Thus try replacing the following line of your code:
   RadGrid1.Rebind();

with the following line:
   tableview.Rebind();

Hope this helps..
Princy.
0
sabarishbabu
Top achievements
Rank 1
answered on 21 Oct 2009, 06:24 AM
Thanks a lot.

It is working.

Tags
Grid
Asked by
sabarishbabu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
sabarishbabu
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or