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

Wrong Detail Item Placed in Edit Mode When Multiple Grid Items Are Expanded

4 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casey
Top achievements
Rank 1
Casey asked on 19 May 2010, 09:05 PM
Hello,

I have a RadGrid with 3 rows. Each of these rows have some child rows. The users are able to expand as many of the rows as they want at 1 time. However, I noticed that if the user expands all 3 rows, and then decides to click "edit" for the first or second detail rows they expanded, then the detail row of the third row is actually opened in Edit Mode. For some reason, the RadGrid is taking the last item that was expanded and using that to decide which item to open in Edit Mode. I have attached files to illustrate what I mean.

In the 'expanded radgrid.png' file I expanded all of the rows of the RadGrid. This works fine. The issue appears when I click the pencil icon, the command name is Edit, for the detail row of the 1st item I expanded. This is shown in the 'expanded radgrid edit mode.png' file. Even though I clicked on the very first detail row of the first grid item, the first detail row of the grid item that was expanded last was really opened in edit mode. It also replaces the detail table underneath the 1st grid item with the detail table underneath the last grid item. This is shown in the 'expanded radgrid after edit mode.png' file.

Any help would be much appreciated. Please let me know if you need more information!

Thanks,
Casey

4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 20 May 2010, 11:25 AM
Hello Casey,

I try to reproduce the described issue, but to no avail. I am sending you a simple example which illustrates how to edit items in hierarchical RadGrid. Please check it out and let me know what differs in your case.

Looking forward for your reply.

Regards,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Casey
Top achievements
Rank 1
answered on 20 May 2010, 01:20 PM
Radoslav,

I tried the example solution you attached and it did work; however, when I replaced my RadGrid definition with your RadGrid definition, my project still didn't work as expected. I was still experiencing the issue I originally posted about. I've pasted the definition for my RadGrid and the events from the code-behind as well.

Please let me know if you see anything that could be causing this behavior.

Thank you!
Casey

<telerik:RadGrid ID="rgInventory" runat="server" AutoGenerateColumns="false" Skin="Vista"   
                       DataSourceID="odsInventory" OnItemCommand="rgInventory_ItemCommand" 
                       EnableViewState="true" OnItemDataBound="rgInventory_ColorByQuantity" 
                       AllowAutomaticInserts="true">  
        <MasterTableView AllowPaging="true" AllowFilteringByColumn="true" 
                         DataKeyNames="FORM_ID" Name="Master" ExpandCollapseColumn-FilterControlWidth="0px" 
                         CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new inventory record" 
                         CommandItemSettings-RefreshText="" CommandItemSettings-ShowRefreshButton="false">  
                                     <EditFormSettings InsertCaption="New Inventory Received"   
                                                       PopUpSettings-Modal="true" > 
                                         <PopUpSettings Modal="True"></PopUpSettings> 
                                     </EditFormSettings> 
            <DetailTables> 
                   <telerik:GridTableView Name="Detail" runat="server" DataKeyNames="FORM_ID" BorderStyle="Solid" 
                                          Width="99%" ClientDataKeyNames="FORM_ID" 
                                          BorderWidth="1px" BorderColor="Black" EditMode="PopUp" 
                                          DataSourceID="odsInventoryReceived" AllowAutomaticUpdates="true" 
                                          AllowAutomaticDeletes="true">   
                   <ParentTableRelation> 
                        <telerik:GridRelationFields DetailKeyField="FORM_ID" MasterKeyField="FORM_ID" /> 
                   </ParentTableRelation> 
                        <Columns>                          
                            <telerik:GridBoundColumn UniqueName="FORM_ID" AllowFiltering="true" 
                                         DataField="FORM_ID" Display="false" 
                                         DataType="System.String" ReadOnly="true">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="WAREHOUSE_ID" AllowFiltering="true" 
                                         DataField="WAREHOUSE_ID" HeaderText="Warehouse" 
                                         DataType="System.String" ReadOnly="true">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="BIN_ID" AllowFiltering="true" 
                                                     DataField="BIN_ID" HeaderText="Bin" 
                                                     DataType="System.String">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="BIN_QTY" AllowFiltering="true" 
                                                     DataField="BIN_QTY" HeaderText="Bin Quantity" 
                                                     Aggregate="Sum" FooterAggregateFormatString="Total= {0}" 
                                                     DataType="System.Int32">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridDateTimeColumn UniqueName="RECEIVED_DT" AllowFiltering="true"   
                                                        FilterControlWidth="125px" 
                                                        DataField="RECEIVED_DT" HeaderText="Date Received" 
                                                        DataType="System.DateTime"   
                                                        DataFormatString="{0:MM/dd/yyyy}">  
                            </telerik:GridDateTimeColumn>                              
                            <telerik:GridCheckBoxColumn UniqueName="OBSOLETE_FLAG" AllowFiltering="true" 
                                            DataField="OBSOLETE_FLAG" HeaderText="Obsolete" 
                                            DataType="System.Boolean" ItemStyle-BackColor="White">  
                                <ItemStyle BackColor="White"></ItemStyle> 
                            </telerik:GridCheckBoxColumn> 
                            <telerik:GridTemplateColumn HeaderText="Edit" UniqueName="TemplateColumn" 
                                            HeaderStyle-Width="20px" ItemStyle-Width="20px" 
                                            AllowFiltering="false">  
                                <ItemTemplate> 
                                    <uc2:Edit ID="Edit1" runat="server" /> 
                                </ItemTemplate> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                                <ItemStyle Width="20px"></ItemStyle> 
                            </telerik:GridTemplateColumn> 
                            <telerik:GridTemplateColumn HeaderText="Delete" UniqueName="TemplateColumn" 
                                            HeaderStyle-Width="20px" ItemStyle-Width="20px" 
                                            AllowFiltering="false">  
                                <ItemTemplate> 
                                    <uc1:Delete ID="Delete1" runat="server" /> 
                                </ItemTemplate> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                                <ItemStyle Width="20px"></ItemStyle> 
                            </telerik:GridTemplateColumn> 
                        </Columns> 
                   </telerik:GridTableView> 
            </DetailTables> 


protected void rgInventory_ItemCommand(object sender, GridCommandEventArgs e)  
    {  
        if (e.Item.OwnerTableView.Name == "Master")  
        {  
            if (e.CommandName == "ExpandCollapse")  
            {  
                Session.Add("SelectedForm", e.Item.Cells[2].Text);  
            }  
        }  
        else if (e.Item.OwnerTableView.Name == "Detail")  
        {  
            if (e.CommandName == "Edit")  
            {  
                Session.Add("OLD_BIN_ID", e.Item.Cells[4].Text);  
                Session.Add("OLD_RECEIVED_DT", e.Item.Cells[6].Text);  
                Session.Add("WAREHOUSE_ID", e.Item.Cells[3].Text);  
            }  
            if (e.CommandName == "Update")  
            {  
                odsInventoryReceived.UpdateParameters.Add("WAREHOUSE_ID", Session["WAREHOUSE_ID"].ToString());  
                odsInventoryReceived.UpdateParameters.Add("OLD_BIN_ID", Session["OLD_BIN_ID"].ToString());  
                odsInventoryReceived.UpdateParameters.Add("OLD_RECEIVED_DT", Session["OLD_RECEIVED_DT"].ToString());  
                odsInventoryReceived.UpdateParameters.Add("LAST_UPDATE_USER", Session["USER_ID"].ToString());  
            }  
            if (e.CommandName == "Delete")  
            {  
                string formId = e.Item.Cells[2].Text;  
                string warehouseId = e.Item.Cells[3].Text;  
                string binId = e.Item.Cells[4].Text;  
                DateTime receivedDt = Convert.ToDateTime(e.Item.Cells[6].Text);  
 
                odsInventoryReceived.DeleteParameters.Clear();  
                odsInventoryReceived.DeleteParameters.Add("WAREHOUSE_ID", warehouseId);  
                odsInventoryReceived.DeleteParameters.Add("FORM_ID", formId);  
                odsInventoryReceived.DeleteParameters.Add("BIN_ID", binId);  
                odsInventoryReceived.DeleteParameters.Add("RECEIVED_DT", receivedDt.ToString("MM/dd/yyyy"));  
            }  
        }  
    }  
    protected void rgInventory_ColorByQuantity(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridDataItem)  
        {  
            if (e.Item.OwnerTableView.Name == "Master")  
            {  
                int diff = FormsWarehouseDB.GetDiff(e.Item.Cells[2].Text);  
                if (diff > 3000)  
                {  
                    e.Item.BackColor = ColorTranslator.FromHtml("#5EFB6E");  
                }  
                else if (diff > 1000 && diff < 3000)  
                {  
                    e.Item.BackColor = ColorTranslator.FromHtml("#FFE87C");  
                }  
                else 
                {  
                    e.Item.BackColor = ColorTranslator.FromHtml("#F75D59");  
                }  
            }  
        }  
    } 

0
Casey
Top achievements
Rank 1
answered on 20 May 2010, 03:22 PM
I found out what was causing this. I had a coding issue where I was not passing the correct FORM_ID to the DataSource that populated the detail table.

Please mark this thread as answered.

Thanks for your help!
Casey
0
Accepted
Radoslav
Telerik team
answered on 21 May 2010, 01:34 PM
Hi Casey,

I am glad you solved the problem. In case you experience any further problems, do not hesitate to contact us again!

Best wishes,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Casey
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Casey
Top achievements
Rank 1
Share this question
or