GridPanel auto-loads when I manually add a row to it

  1. #1

    [CLOSED] GridPanel auto-loads when I manually add a row to it

    Hi,

    I have a grid panel that I add to using the results of a drag/drop action. However, as soon as the item is "dropped" into the grid panel, it triggers a reload of the contents of the grid panel. I've tried setting a bunch of properties on the store to stop this from happening, but every add to the gridpanel's store triggers a reload. Here is my code:

    The HTML:

    <ext:GridPanel Margins="10 10 10 10" ID="GridPanel2" runat="server" DDGroup="firstGridDDGroup"
                                    EnableDragDrop="true" StripeRows="true" AutoExpandColumn="EmailAddress" 
                                    Width="300" MaxWidth="300" Title="Users in Role">
                                    <Store>
                                        <ext:Store ID="UsersSelectedStore" runat="server" RemoteSort="true" UseIdConfirmation="true" AutoDataBind="false" AutoLoad="false" AutoSave="false" RefreshAfterSaving="None">
                                            <Proxy>
                                                <ext:HttpProxy Url="/UserData/GetUsersByRole/"/>
                                            </Proxy>
                                            <UpdateProxy>
                                                <ext:HttpWriteProxy Url="/UserData/SaveSelectedUsers/" />
                                            </UpdateProxy>
                                            <Reader>
                                                <ext:JsonReader IDProperty="UserId" Root="data" TotalProperty="total">
                                                    <Fields>
                                                        <ext:RecordField Name="UserId" SortDir="ASC" />
                                                        <ext:RecordField Name="Forename" />
                                                        <ext:RecordField Name="Surname" />
                                                        <ext:RecordField Name="CreationDate" Type="Date" />
                                                        <ext:RecordField Name="EmailAddress" />
                                                    </Fields>
                                                </ext:JsonReader>
                                            </Reader>
                                            <BaseParams>
                                                <ext:Parameter Name="roleid" Value="#{txtHiddenRoleId}.getValue()" Mode="Raw" />
                                            </BaseParams>
                                            <SortInfo Field="UserId" Direction="ASC" />
                                        </ext:Store>
                                    </Store>
                                    <ColumnModel>
                                        <Columns>
                                            <ext:Column ColumnID="Surname" Header="Surname" Width="80" DataIndex="Surname" />
                                            <ext:Column Header="Forename" Width="80" DataIndex="Forename" />
                                            <ext:Column Header="EmailAddress" Width="80" DataIndex="EmailAddress" />
                                        </Columns>
                                    </ColumnModel>
                                    <SelectionModel>
                                        <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" />
                                    </SelectionModel>
                                </ext:GridPanel>
    
        <ext:DropTarget ID="DropTarget2" runat="server" Target="={GridPanel2.view.scroller.dom}"
            Group="secondGridDDGroup" AutoDataBind="false">
            <NotifyDrop Fn="notifyDrop2" />
        </ext:DropTarget>
    The Javascript that adds a new row to the panel

            var notifyDrop2 = function (ddSource, e, data) {
                // Loop through the selections
                //alert(Ext.get('UserIds'));
                Ext.each(ddSource.dragData.selections, function (record) {
                    addRow(UsersSelectedStore, record, ddSource);
                });
                return true;
            };
    
            var addRow = function (store, record, ddSource) {
                // Search for duplicates
                var foundItem = store.findExact('EmailAddress', record.data.Name);
    
                // if not found
                if (foundItem == -1) {
                    //Remove Record from the source
                    ddSource.grid.store.remove(record);
    
                    store.add(record);
    
                    // Call a sort dynamically
                    store.sort('Surname', 'ASC');
                }
            };
    Last edited by mattwoberts; Jan 04, 2011 at 2:56 PM.
  2. #2
    Ah.. Seems that my call to sort the grid was forcing a reload, since it's set to sort on the server side.

Similar Threads

  1. Replies: 0
    Last Post: May 09, 2012, 8:27 AM
  2. Replies: 4
    Last Post: Jun 14, 2010, 11:12 AM
  3. GridPanel Auto Paging and Sorting
    By Dominik in forum 1.x Help
    Replies: 2
    Last Post: May 17, 2010, 9:24 AM
  4. Adding rows to a GridPanel manually
    By henricook in forum 1.x Help
    Replies: 0
    Last Post: May 14, 2010, 4:20 AM
  5. [CLOSED] [1.0] gridpanel loads blank rows
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 02, 2010, 3:54 AM

Posting Permissions