[CLOSED] [#489] Issue with ImageCommandColumn on GridPanel

  1. #1

    [CLOSED] [#489] Issue with ImageCommandColumn on GridPanel

    Hi,

    In Ext V2.5 GridPanel has grouping and 2 ImageCommandColumns for Delete and Edit. When gridpanel expanded all groups, getting correct record data when we click on Edit/Delete. When collapse first group of data and trying to edit/delete record from next group of data getting first group data of same index.

    Please provide solution for this issue. You can replicate same error in Ext Examples. Please find the attached images for reference.
    Link: https://examples2.ext.net/#/GridPane...Image_Command/

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Group Image Commands - Ext.NET Examples</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    
        <script>
            var prepareCommand = function (grid, command, record, row) {
                // you can prepare group command
                if (command.command == 'Delete' && record.data.Price < 5) {
                    command.hidden = true;
                    command.hideMode = 'visibility'; //you can try 'display' also                 
                }
            };
            
            var prepareGroupCommand = function (grid, command, groupId, group) {
                // you can prepare group command
            };
    
            var getAdditionalData = function (data, idx, record, orig) {            
                return {
                    rowBodyColspan : record.fields.getCount(),
                    rowBody: Ext.String.format('<div style=\'padding:0 5px 5px 5px;\'>The {0} [{1}] requires light conditions of <i>{2}</i>.<br /><b>Price: {3}</b></div>', data.Common, data.Botanical, data.Light, Ext.util.Format.usMoney(data.Price))
                };
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <h1>ImageCommandColumn is a simpler and faster version of CommandColumn</h1>
    
            <ext:GridPanel
                runat="server"            
                Collapsible="true" 
                Width="600"             
                Height="350"            
                Title="Plants" 
                Frame="true">
                <Store>
                    <ext:Store runat="server" GroupField="Light">
                        <Proxy>
                            <ext:AjaxProxy Url="../../Shared/PlantService.asmx/Plants">
                                <ActionMethods Read="POST" />
                                <Reader>
                                    <ext:XmlReader Record="Plant" />
                                </Reader>
                            </ext:AjaxProxy>
                        </Proxy>
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="Common" />
                                    <ext:ModelField Name="Botanical" />
                                    <ext:ModelField Name="Zone" Type="Int" />
                                    <ext:ModelField Name="ColorCode" />
                                    <ext:ModelField Name="Light" />
                                    <ext:ModelField Name="Price" Type="Float" />
                                    <ext:ModelField Name="Availability" Type="Date" />
                                    <ext:ModelField Name="Indoor" Type="Boolean" />
                                </Fields>
                            </ext:Model>
                        </Model>
                        <Sorters>
                            <ext:DataSorter Property="Common" Direction="ASC" />
                        </Sorters>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column 
                            runat="server" 
                            Text="Common Name" 
                            DataIndex="Common" 
                            Flex="1" 
                            />
                        <ext:Column 
                            runat="server" 
                            Text="Light" 
                            DataIndex="Light" 
                            Width="130" 
                            />
                        <ext:Column 
                            runat="server" 
                            Text="Price" 
                            DataIndex="Price" 
                            Width="70" 
                            Align="right" 
                            Groupable="false">
                            <Renderer Format="UsMoney" />
                        </ext:Column>
                        <ext:DateColumn 
                            runat="server" 
                            Text="Available" 
                            DataIndex="Availability" 
                            Width="95" 
                            Groupable="false" 
                            Format="yyyy-MM-dd" 
                            />
                        <ext:Column 
                            runat="server" 
                            Text="Indoor?" 
                            DataIndex="Indoor" 
                            Width="55" 
                            />
                        <ext:ImageCommandColumn runat="server" Width="170">
                            <Commands>
                                <ext:ImageCommand CommandName="Delete" Icon="Delete" Text="Delete">
                                    <ToolTip Text="Delete" />
                                </ext:ImageCommand>
                                <ext:ImageCommand CommandName="Edit" Icon="TableEdit" Text="Edit">
                                    <ToolTip Text="Edit" />
                                </ext:ImageCommand>
                                <ext:ImageCommand CommandName="Disabled" Icon="PageWhiteEdit" Text="Disabled" Disabled="true">
                                    <ToolTip Text="Edit" />
                                </ext:ImageCommand>
                            </Commands>
                            
                           
                            <Listeners>
                                <Command Handler="Ext.Msg.alert(command, record.data.Common);" />
                            </Listeners>
                        </ext:ImageCommandColumn>
                    </Columns>
                </ColumnModel>
                
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" Mode="Multi" />
                </SelectionModel>
    
                <View>
                    <ext:GridView runat="server" StripeRows="false" TrackOver="false" />
                </View>
                
                <Features>
                    <ext:Grouping 
                        runat="server" 
                        HideGroupedHeader="true" 
                        GroupHeaderTplString='{columnName}: {name} ({[values.rows.length]} {[values.rows.length > 1 ? "Items" : "Item"]})' 
                        />
    
                    <ext:RowBody runat="server">
                        <GetAdditionalData Fn="getAdditionalData" />
                    </ext:RowBody>
    
                    <ext:RowWrap runat="server" />
                </Features>         
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Attached Thumbnails Click image for larger version. 

Name:	ImageCommand1.GIF 
Views:	39 
Size:	46.5 KB 
ID:	10841   Click image for larger version. 

Name:	ImageCommand2.GIF 
Views:	36 
Size:	99.9 KB 
ID:	10851  
    Last edited by Daniil; Oct 28, 2014 at 4:26 PM. Reason: [CLOSED]
  2. #2
    Please give solution ASAP.

    Thank you.
  3. #3
    Hi @iansriley,

    Thank you for the report. It is a known issue.
    https://github.com/extnet/Ext.NET/issues/447

    Unfortunately, we don't have a solution. At this point the only thing we can suggest not to use a Grouping and a RowBody together.
  4. #4
    Thanks for response.

    Without RowBody also getting same issue. I have removed RowBody control and collapsed first group header, when click on Delete getting different record.

    Please suggest with alternate solution or controls to show Edit, Delete icon with commands.

    Thank you.
  5. #5
    You are right. It is reproducible without a RowBody. Here is a test case.

    Steps:

    1. Collapse the first group.
    2. Click the ImageCommand in the second group.
    3. It shows wrong data.

    Example
    <%@ Page Language="C#" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new object[] 
                { 
                    new object[] { "group1", "1", "1" },
                    new object[] { "group1", "11", "11" },
                    new object[] { "group1", "111", "111" },
                    new object[] { "group2", "2", "2" },
                    new object[] { "group2", "22", "22" },
                    new object[] { "group2", "222", "222" }
                };
            }
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:GridPanel ID="GridPanel1" runat="server">
                <Store>
                    <ext:Store runat="server" GroupField="groupId">
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="groupId" />
                                    <ext:ModelField Name="test1" />
                                    <ext:ModelField Name="test2" />
                                </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column runat="server" Text="GroupId" DataIndex="groupId" />
                        <ext:Column runat="server" Text="Test1" DataIndex="test1" />
                        <ext:Column runat="server" Text="Test2" DataIndex="test2" />
    
                        <ext:ImageCommandColumn runat="server" Width="170">
                            <Commands>
                                <ext:ImageCommand CommandName="Delete" Icon="Delete" Text="Delete">
                                    <ToolTip Text="Delete" />
                                </ext:ImageCommand>
                                <ext:ImageCommand CommandName="Edit" Icon="TableEdit" Text="Edit">
                                    <ToolTip Text="Edit" />
                                </ext:ImageCommand>
                            </Commands>
                            <Listeners>
                                <Command Handler="Ext.Msg.alert(command, record.data.test1);" />
                            </Listeners>
                        </ext:ImageCommandColumn>
                    </Columns>
                </ColumnModel>
                <Features>
                    <ext:Grouping runat="server" />
                </Features>
            </ext:GridPanel>
        </form>
    </body>
    </html>
  6. #6
    Created an Issue.
    https://github.com/extnet/Ext.NET/issues/489

    It has been fixed in the SVN trunk, the revision #5837.

    Thank you again for the report.
  7. #7
    what is the solution, how to incorporate in my project?

    Do i need to take the latest dll or update any code?

    Thank you.
  8. #8
    Quote Originally Posted by iansriley View Post
    what is the solution
    There are some changes in JavaScript code of ImageCommandColumn.

    Quote Originally Posted by iansriley View Post
    how to incorporate in my project?
    Since the changes in JavaScript only you can add the override to the page's <head>.
    Ext.grid.column.ImageCommand({
        // overridden methods
    });
    Quote Originally Posted by iansriley View Post
    Do i need to take the latest dll
    Yes, you can also grab the latest sources for SVN and build it, getting the updated dll.
  9. #9
    Hi,
    I'm sorry but i haven't the SVN access...
    It's possible have the FIX
    Thx so much
    Guglielmo
  10. #10
    Hi @web_manufacturing,

    It is one of the differences between regular and premium members. Premium members have access to the latest sources and, respectively, to all the fixes, but regular members have to wait the next public release.

    You are always welcome to buy a Premium Support Subscription;)

Similar Threads

  1. Replies: 2
    Last Post: Aug 02, 2013, 5:16 AM
  2. Replies: 6
    Last Post: Mar 14, 2013, 12:00 PM
  3. ImageCommandColumn
    By gisxiaowei in forum 1.x Help
    Replies: 3
    Last Post: Aug 26, 2009, 4:46 PM
  4. [CLOSED] GridPanel and ImageCommandColumn...
    By state in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 03, 2009, 5:40 PM

Tags for this Thread

Posting Permissions