[CLOSED] Grid image command column shifts grid cells

  1. #1

    [CLOSED] Grid image command column shifts grid cells

    I have a grid with an image command column and Check box selection model. When you click the command column, everything shifts to the left, hiding the checkbox selection checkboxes. Then you have to click the command again to actually execute the command.

    <%@ Page Language="vb" %>
    
    <!DOCTYPE html>
    
    <script runat="server">
        Private ReadOnly Property TestData() As Object()
            Get
                Dim now As DateTime = DateTime.Now
    
                Return New Object() {New Object() {"PC5a8AdEsKHJssf0dQSY0yq+YbvdbZh5gKZkr9oGZcI10gcqXrzw+fN6otHwujgdYpe8+6M/AEParkzJIvI3mPLG4Unt2mo0p370OuZUTpQbFaRU2NpWjQ==", "3m Co", 71.72, 0.02, 0.03, now},
                    New Object() {"Vzsg+QuKvBT+YrxSc4Fjo4PbnXc30rhsQyRK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QubnXc30rhsQyRK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsgnXc30rhsQyRK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+Y0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4PbnXc30rhsQyRKP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4PbnXc30rhsQyRK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxScK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4FnRzYx1JedUuIbn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4Px1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4Pn1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4PbnXUu2Ibn5uVP68cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ==", "Boeing Co.", 75.43, 0.53, 0.71, now},
                    New Object() {"jWDvWMKf+WEkV9o+y/n5XiajTQtE2Hzv0VguMIxWRbbHkFtWKmkx4e3eFwGeLs7T7BrVxfHglj05sWJ8G7+MkaPdQHIoPdQP0KfLvSngH9BANF3EV1bwzA==", "Government Motors Corporation", 30.27, 1.09, 3.74, now}}
            End Get
        End Property
    
        Protected Sub Page_Load(sender As Object, e As EventArgs)
            If Not Ext.Net.X.IsAjaxRequest Then
                Me.Store1.DataSource = Me.TestData
    
                'attempt to select second row
                Dim rowID As String = "Vz+EvcgoZ2PjG8HeRGsg+QuKvBT+YrxSc4Fjo4PbnXc30rhsQyRK0V2fnRzYx1JedUu2Ibn5uVP6a4G8cpltKVZz4kasruS0oSxq+GqxA1mhzS6kPE/2rQ=="
                Dim sm As CheckboxSelectionModel = grdComposite.GetSelectionModel
                sm.ClearSelection()
                sm.SelectedRows.Add(New SelectedRow(rowID))
                Ext.Net.X.Call("setGridPageById", rowID)
            End If
        End Sub
    
        Protected Sub MyData_Refresh(sender As Object, e As StoreReadDataEventArgs)
            Me.Store1.DataSource = Me.TestData
            Me.Store1.DataBind()
        End Sub
    </script>
    
    <html>
    <head runat="server">
        <title></title>
        <script type="text/javascript">
            var overIt = function () {
                console.log('over handler');
            }
    
      <%--      var setGridPage = function() {
                var grd = <%= grdComposite.ClientID%>;
                grd.getStore().loadPage(grd.getStore().findPage(grd.getView().getSelection()[0]));
            }--%>
    
            var setGridPageById = function (recordId) {
                var grd = <%= grdComposite.ClientID %>,
                    store = grd.getStore(),
                    idProperty = grd.getStore().getModel().idProperty,
                    record = store.findRecord(idProperty, recordId);
    
                if (record) {
                    store.loadPage(store.findPage(record));
                }
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ext:ResourceManager runat="server" />
            <ext:Viewport ID="vp1" runat="server" Layout="FitLayout" Scrollable="Both">
                <Items>
                    <ext:GridPanel
                        ID="grdComposite"
                        runat="server"
                        Title="Grid"
                        BodyPadding="15"
                        Padding="10"
                        HeightSpec="100%"
                        >
                        <Store>
                            <ext:Store
                                ID="Store1"
                                runat="server"
                                RemoteSort="false"
                                OnReadData="MyData_Refresh"
                                PageSize="5">
                                <Model>
                                    <ext:Model runat="server" IDProperty="EncryptedID">
                                        <Fields>
                                            <ext:ModelField Name="EncryptedID" />
                                            <ext:ModelField Name="company" Type="string" />
                                            <ext:ModelField Name="price" Type="Float" />
                                            <ext:ModelField Name="change" Type="Float" />
                                            <ext:ModelField Name="pctChange" Type="Float" />
                                            <ext:ModelField Name="lastChange" Type="Date" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                        <ColumnModel runat="server">
                            <Columns>
                                <ext:Column runat="server" Text="Company" DataIndex="company" Flex="1">
                                    <Editor>
                                        <ext:TextField runat="server" />
                                    </Editor>
                                </ext:Column>
                                <ext:Column runat="server" Text="Price" Width="75" DataIndex="price">
                                    <Editor>
                                        <ext:TextField runat="server" />
                                    </Editor>
                                </ext:Column>
                                <ext:Column runat="server" Text="Change" Width="75" DataIndex="change" />
                                <ext:Column runat="server" Text="Change" Width="75" DataIndex="pctChange" />
                                <ext:DateColumn
                                    runat="server"
                                    Text="Last Updated"
                                    Width="120"
                                    DataIndex="lastChange"
                                    Format="HH:mm:ss" />
    
                                <ext:ImageCommandColumn width="50" Align="Center" runat="server" ID="cmdEditAllocation" >
                                   
                                    <Commands>
                                        <ext:ImageCommand
                                            Icon="ApplicationEdit"
                                            ToolTip-Text="Edit Allocation"
                                            CommandName="edit" >
                                        </ext:ImageCommand>
                                    </Commands>
                                </ext:ImageCommandColumn>
    
                            </Columns>
                        </ColumnModel>
                        <SelectionModel>
                            <ext:CheckboxSelectionModel
                                    runat="server"
                                    ID="grdCompositeSelectionModel"
                                    AllowDeselect="false"
                                    Mode="Single">
                            </ext:CheckboxSelectionModel>
                        </SelectionModel>
                        <BottomBar>
                            <ext:PagingToolbar runat="server" />
                        </BottomBar>
                    </ext:GridPanel>
                </Items>
            </ext:Viewport>
        </div>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Aug 21, 2017 at 5:12 PM.
  2. #2
    Hello @rmelancon!

    Setting the BodyPadding="15" on your example is breaking the columns' sync. Take a closer look on your example, how the check column is misaligned and taking over part of the "Company" column.

    If you just remove it, then your test case works fine. If you look at the Ext.grid.Panel.bodyPadding documentation, you'll see that's just a setting inherited from the panel and using it is expected to bring problem with several aspects of a grid, likely locking as well, and any grid panel column aligning related feature.

    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Not sure why the BodyPadding was used, probably trying to address some other layout issue. In any case, removing it did the trick, thanks.
  4. #4
    Thanks for the feedback, @rmelancon! Glad it was an acceptable change, and it actually helped you out!

    Probably if you did simplify just a little more your test case you yourself would see the error go off, so sometimes simplifying the more you can, may reveal the problem.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 5
    Last Post: Sep 02, 2014, 1:15 PM
  2. [CLOSED] Grid Column Command...need Grid parameter!
    By rthiney in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 18, 2013, 9:11 PM
  3. Replies: 1
    Last Post: May 16, 2012, 12:57 PM
  4. Replies: 9
    Last Post: May 09, 2012, 9:22 AM
  5. Grid Image Command's Mouse Cursor
    By dtamils in forum 1.x Help
    Replies: 2
    Last Post: Aug 05, 2011, 1:51 AM

Posting Permissions