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

CommandItemTemplate Question - Detail Tables Edit Indexes Count and How to Make a Detail Table Row Selected /Last Inserted Updated Row at All Times

2 Answers 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 30 May 2012, 07:39 PM

Folks,

Using VS2010 with RadControls for Ajax Q1 2012.

I need some help with following issues:

1) For Example, while using Command Item Template, I can hide the the EditSelected Command Button based on RadGrid1.EditIndexes.Count of Master Table, How can I accomplish the same result  with Child Table (i.e. hide EditSelected Command Button based on RadGrid1.EditIndexes.Count of Child Table)?  Basically I do not want to show Child Table  EditSelected Command if there are no Child rows.

To get Child Table Edit Indexes count I tried to below line of code but is not working.

Visible='<%# RadGrid1.MasterTableView.DetailTables[0].EditIndexes.Count > 0 %>'>

Below is my Master/Detail Command Items Template.

<Mastertableview width="100%" commanditemdisplay="Top" datasourceid="SqlDataSource1" name = "Master"
       datakeynames="CustomerID">
           <CommandItemTemplate>
               <div style="padding: 5px 5px;">
                   Custom command item template for Master table     
                    
                   <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected"
                   Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;"
                   alt="" src="Images/Edit.gif" />Edit selected Master Row</asp:LinkButton>  
                    
                   <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited"
                   Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;"
                   alt="" src="Images/Update.gif" />Update Selected Master Row</asp:LinkButton>  
                   '''
                   '''
               </div>
           </CommandItemTemplate>
       
                   <DetailTables>
                      <telerik:GridTableView DataKeyNames="OrderID,ProductID" DataSourceID="SqlDataSource3"
                               Width="100%" runat="server" CommandItemDisplay="Top" Name="Details">
 
                       <CommandItemTemplate>
                       <div style="padding: 5px 5px;">
                        Custom command item template for Child Table     
                         
                         <asp:LinkButton ID="btnEditSelectedChildRow" runat="server" CommandName="EditSelected"
                          Visible='<%# RadGrid1.MasterTableView.DetailTables[0].EditIndexes.Count > 0 %>'>
                          <img style="border:0px;vertical-align:middle;"
                          alt="" src="Images/Edit.gif" />Edit selected Child Row</asp:LinkButton>  
                    
                          <asp:LinkButton ID="btnUpdateSelectedChildRow" runat="server" CommandName="UpdateEdited"
                           Visible='<%# RadGrid1.MasterTableView.DetailTables[0].EditIndexes.Count > 0 %>'>
                           <img style="border:0px;vertical-align:middle;"
                           alt="" src="Images/Update.gif" />Update Selected Child Row</asp:LinkButton>  
                           '''
                           '''
                            
                       </CommandItemTemplate>
 
 
                   </telerik:GridTableView>
                  </DetailTables>
                </Mastertableview>


2)  Below link from Telerik Documentation shows Making a Grid Row Selected at All Times (similar to WinForms grids). How can I accomplish the same result with Child Table (I have multiple Child Tables)?

http://www.telerik.com/help/aspnet-ajax/grid-selected-row-at-all-times.html

3) Below Thread solution by Princy demonstrated Select Inserted/Updated row after performing command in Master Table. How can I accomplish the same result with Child Table (I have multiple Child Tables)?

http://www.telerik.com/community/forums/aspnet-ajax/grid/select-inserted-updated-row-after-performing-command.aspx


Thank you very much for any help.

Sincerely

gc_0620






2 Answers, 1 is accepted

Sort by
0
gc_0620
Top achievements
Rank 1
answered on 01 Jun 2012, 09:21 PM
Any Suggestions?

For the time being, I would like to know is it possible  do not show Child Table EditSelected Command item from its CommanditemTemplate if there are no Child rows?

Thanks

GC_0620
0
Andrey
Telerik team
answered on 04 Jun 2012, 12:56 PM
Hello,

If I understand correctly what your requirement is you should check the Items collection count instead of the EditIndexes:

Visible='<%# RadGrid1.MasterTableView.DetailTables[0].Items.Count > 0 %>'>

Give this approach a try and check whether this is the desired functionality.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
gc_0620
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or