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

Multi-Edit Issue

2 Answers 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 15 Oct 2008, 04:14 PM
I have a hierarchial grid with 3 levels.  Only the deepest level is editable.  Instead of having a link button on each row, I have checkboxes and a link button in the CommandItemDisplay to allow for edit mode of multiple rows at once. 

When selecting 1 row at a time for editing, everything works fine.  The problem is when I go into edit mode for multiple rows.  For example, I have 2 rows and both are checked.  The first row doesn't go into edit mode, but the second row does. 

The code executes without errors and all selected rows are getting the Edit property set to true, but after rebinding I do not get the expected results of 2 rows in edit mode.

Here is my code:

Protected Sub grdOR_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles grdOR.PreRender  
 
        If Not ViewState("grdOR_EditIndex"Is Nothing Then 
 
            Dim Keys() As String = ViewState("grdOR_EditIndex").ToString.Split(",")  
            Dim nestedTableViewSKU As GridTableView = CType(grdOR.MasterTableView.Items(Convert.ToInt32(Keys(0))), GridDataItem).ChildItem.NestedTableViews(0)  
            Dim nestedTableViewStore As GridTableView = CType(nestedTableViewSKU.Items(Convert.ToInt32(Keys(1))), GridDataItem).ChildItem.NestedTableViews(0)  
 
            For Each item As GridDataItem In nestedTableViewStore.Items  
 
                Dim chk As CheckBox = DirectCast(item("chkEdit").Controls(0), CheckBox)  
 
                If chk.Checked Then 
 
                    item.Edit = True 
 
                End If 
 
            Next 
 
            nestedTableViewStore.Rebind()  
 
        End If 
 
    End Sub 
 
    Protected Sub grdOR_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdOR.ItemCommand  
 
        Select Case e.CommandName  
 
            Case "MULTIEDIT" 
 
                Dim SKUItem As GridDataItem = CType(e.Item.OwnerTableView.ParentItem, GridDataItem)  
                Dim StyleItem As GridDataItem = CType(SKUItem.OwnerTableView.ParentItem, GridDataItem)  
 
                ViewState("grdOR_EditIndex") = StyleItem.ItemIndex & "," & SKUItem.ItemIndex  
 
        End Select 
 
    End Sub 
 

<telerik:RadGrid ID="grdOR" runat="server" AutoGenerateColumns="False" GridLines="None" Width="100%" Skin="WebBlue" AllowMultiRowSelection="True" > 
            <MasterTableView DataKeyNames="STYL_SEQ_NUM,RVD_QTY" AllowAutomaticUpdates="True" NoDetailRecordsText="No SKU records to display." NoMasterRecordsText="No Style records to display." EditMode="InPlace">  
                <DetailTables> 
                    <telerik:GridTableView runat="server" DataKeyNames="STYL_SEQ_NUM,MSC_MDSE_NUM" NoDetailRecordsText="No Store records to display." > 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn Visible="True">  
                            <HeaderStyle Width="20px" /> 
                        </ExpandCollapseColumn> 
                        <Columns> 
                            <telerik:GridBoundColumn DataField="CLR_CDE" HeaderText="Color Code" UniqueName="CLR_CDE" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="CLR_DCD" HeaderText="Color Desc" UniqueName="CLR_DCD" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="STYL_SEQ_NUM" HeaderText="SSN" UniqueName="STYL_SEQ_NUM" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="MSC_MDSE_NUM" HeaderText="MSC" UniqueName="MSC_MDSE_NUM" > 
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY">  
                                <HeaderStyle Width="50px" /> 
                                <ItemStyle Width="50px" /> 
                            </telerik:GridBoundColumn> 
                            <telerik:GridButtonColumn ButtonType="PushButton" Text="Zero" UniqueName="ZERO" CommandName="ZEROSKU">  
                                <HeaderStyle Width="50px" /> 
                                <ItemStyle Width="50px" /> 
                            </telerik:GridButtonColumn> 
                        </Columns> 
                        <DetailTables> 
                            <telerik:GridTableView runat="server" DataKeyNames="STOR_CDE,MSC_MDSE_NUM,RVD_QTY" EditMode="InPlace" AllowAutomaticUpdates="True" CommandItemDisplay="Top" Width="100%" > 
                                <RowIndicatorColumn> 
                                    <HeaderStyle Width="20px" /> 
                                </RowIndicatorColumn> 
                                <ExpandCollapseColumn> 
                                    <HeaderStyle Width="20px" /> 
                                </ExpandCollapseColumn> 
                                <Columns> 
                                    <telerik:GridClientSelectColumn UniqueName="chkEdit" /> 
                                    <%--<telerik:GridTemplateColumn UniqueName="CheckCol" HeaderText="CheckCol" >    
                                     <ItemTemplate>    
                                         <asp:CheckBox ID="chkStore" runat="server" />    
                                     </ItemTemplate>    
                                    </telerik:GridTemplateColumn> --%> 
                                    <telerik:GridTemplateColumn DataField="STOR_CDE" HeaderText="Store" UniqueName="STOR_CDE" > 
                                        <ItemTemplate> 
                                            <%#Eval("STOR_CDE")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <%#Eval("STOR_CDE")%> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="ORDR_QTY" HeaderText="Quantity" UniqueName="ORDR_QTY">  
                                        <ItemTemplate> 
                                            <%#Eval("ORDR_QTY")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <%#Eval("ORDR_QTY")%> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="MSC_MDSE_NUM" HeaderText="MSC" UniqueName="MSC_MDSE_NUM">  
                                        <ItemTemplate> 
                                            <%#Eval("MSC_MDSE_NUM")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <%# Eval("MSC_MDSE_NUM") %> 
                                        </EditItemTemplate> 
                                    </telerik:GridTemplateColumn> 
                                    <telerik:GridTemplateColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY">  
                                        <ItemTemplate> 
                                            <%#Eval("RVD_QTY")%> 
                                        </ItemTemplate> 
                                        <EditItemTemplate> 
                                            <asp:TextBox ID="txtRevisedQuantity" runat="server" Text='<%# Bind("RVD_QTY") %>' /> 
                                        </EditItemTemplate> 
                                        <HeaderStyle Width="110px" /> 
                                        <ItemStyle Width="110px" /> 
                                    </telerik:GridTemplateColumn> 
                                </Columns> 
                                <EditFormSettings> 
                                    <EditColumn UniqueName="EditCommandColumn1">  
                                    </EditColumn> 
                                </EditFormSettings> 
                                <CommandItemTemplate>     
                                    <asp:LinkButton ID="btnEdit" runat="server" CommandName="MULTIEDIT" Text="Edit" Visible="true" OnClientClick="setEditMode('EDIT')" />    
                                    <asp:LinkButton ID="btnUpdate" runat="server" CommandName="MULTIUPDATE" Text="Update" Visible="false" OnClientClick="setEditMode('UPDATE')" />     
                                    <asp:LinkButton ID="btnCancel" runat="server" CommandName="MULTICANCEL" Text="Cancel" Visible="false" OnClientClick="setEditMode('CANCEL')" />    
                                </CommandItemTemplate> 
                            </telerik:GridTableView> 
                        </DetailTables>                         
                    </telerik:GridTableView> 
                </DetailTables> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Visible="True">  
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="ITEM_DES" HeaderText="Desc" UniqueName="ITEM_DES">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="VEN_STYL_NUM" HeaderText="Style" UniqueName="VEN_STYL_NUM">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="STYL_SEQ_NUM" HeaderText="SSN" UniqueName="STYL_SEQ_NUM">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="RVD_QTY" HeaderText="RVD_QTY" UniqueName="RVD_QTY">  
                        <ItemTemplate> 
                            <%#Eval("RVD_QTY")%> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <asp:TextBox ID="txtRevisedStyle" runat="server" Text='<%# Bind("RVD_QTY") %>' /> 
                        </EditItemTemplate> 
                        <HeaderStyle Width="50px" /> 
                        <ItemStyle Width="50px" /> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridButtonColumn ButtonType="PushButton" Text="Zero" UniqueName="ZERO" CommandName="ZEROSTYLE">  
                        <HeaderStyle Width="50px" /> 
                        <ItemStyle Width="50px" /> 
                    </telerik:GridButtonColumn> 
                </Columns> 
                <EditFormSettings > 
                    <PopUpSettings Modal="True" /> 
                </EditFormSettings> 
            </MasterTableView> 
            <ClientSettings> 
                <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
                <Selecting AllowRowSelect="True" /> 
                <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" OnGridCreated="GridCreated"/>  
            </ClientSettings> 
        </telerik:RadGrid> 

Please advise.

Rob

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Oct 2008, 04:47 AM
Hi Rob,

Try setting the AllowMultiRowEdit property to true in the aspx as shown below.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server"  AllowMultiRowEdit="true" > 
             



Thanks
Shinu
0
Rob
Top achievements
Rank 1
answered on 20 Oct 2008, 02:32 PM
Yep, that's all it took to get it working.  Thanks for the help.  I'm new to RadControls if you can't tell.  :)
Tags
Grid
Asked by
Rob
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Rob
Top achievements
Rank 1
Share this question
or