Results 1 to 7 of 7

Thread: Problem loading the grid store

  1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    4

    Default Problem loading the grid store

    Hello all

    I have a problem reloading the store after deleting a record in the grid.
    After deleting the record, the grid loads for a few seconds and the record is getting deleted at the back end.
    But ExtJs was still trying to fetch the deleted records from the source, which is generating an exception in the java code. I am using a pagination grid which displays 10 records on every page.Whenever i delete a record, the page is unable to fill the void left by the deleted records. But when i click on the refresh icon on the pagination bar, it is fetching the records in place of the deleted records. Please share your thoughts on this issue.

    Thanks in advance.

    This is the function i call every time i delete a record..

    Code:
    function Delete(isLocked, documentId)
    {
        if (isLocked == "false") {
            var panelContent;
            var win;
            var button = Ext.get('Delete');
            win = new Ext.Window({
                        // applyTo:'help-win',
                        title : 'Delete details',
                        id : 'deletewin',
                        closable : false,
                        closeAction : 'hide',
                        width : 200,
                        height : 120,
                        border : false,
                        plain : true,
                        autoLoad : {
                            url : 'deleteRevision.jsp',
                            params : {
                                'documentId' : documentId
                            },
                            scripts : true,
                            nocache : true
                        },
    
                        buttons : [{
                                    text : 'OK',
                                    id : 'message_box',
                                    cls : 'x-icon-btn',
                                    iconCls : 'x-icon-btn-ok',
                                    handler : function() {
                                    var record = grid.getSelectionModel().getSelected();
                                        if(record != undefined)
                                            grid.store.remove(record);
                                            Ext.getCmp("deletewin").close();
                                            grid.getStore().reload();
                                                                         
                                        
                                    }
                                }]
                    });
            win.show();
        }
    }
    This is my store definition

    Code:
    dataStore = new Ext.data.Store({
                            // load using script tags for cross domain
                            proxy : new Ext.data.HttpProxy({
                                        url : 'assets.jsp',
                                        method : 'GET'
                                    }),
                            // let it know about the reader
                            reader : reader,
                            autoLoad : {
                                params : {
                                    start : 0,
                                    limit : 10
                                }
                            }
                        });

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2009
    Location
    Amsterdam, The Netherlands
    Posts
    245

    Default

    You're doing it in a wrong way. When you click save you have two options: Or you use Ext.Direct and then just use store.save(); and that's it, or you use a normal Ajax.request and on the callback you load the store again.

    Don't use defer!! Somebody would kill you for that :P

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    4

    Default

    Thanks for the prompt reply.

    I wasn't saving anything in the grid. I just wanted to reload the grid with all the new records replacing the deleted ones. I am a beginner in ExtJs, so if you don't mind, please care to explain in detail.

  4. #4
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    Code:
    grid.store.remove(record);
    Ext.getCmp("deletewin").close();
    grid.getStore().reload();
    this is your problem.
    1) you close the window before doing something else
    2) you don't need to reload when removing a record

    try this way:
    Code:
    var gridstore = grid.store;
    gridstore.remove(record);
    gridstore.commit(); // this should fire a request to delete the record in your BE
    win.close(); //you already have a reference to your window
    grid.getStore().reload();
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Posts
    4

    Default

    Steffenk, Thanks for the reply.

    Please see the attachment.

    I did as you told, but the problem still persists.
    If i remove the line grid.getStore().reload(), then it doesnt generate any exception,
    but it also doesnt fetch the new records into the page. So i have to reload the grid after deleting any record. How can we fetch the new records into the current page without a reload.(Even reload isnt fetching the records). We are supposed to have ten records on every page, then if we delete any of these records, it should reload and readjust the page with 10 records by fetching new records in place of the deleted ones.
    Attached Images Attached Images

  6. #6
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    Then something else is wrong. The grid displays the records from store. If you remove a record, it is removed from grid too.
    Are you sure you have correct id's for the records? Are you sure you fetched correct record?

    Try with console first:
    Code:
    datastore.remove(datastore.getAt(0));
    The grid should be updated as well.
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  7. #7
    Sencha User
    Join Date
    Mar 2011
    Posts
    4

    Default

    Yes , all the records with the correct ID's were getting deleted.
    If you see the attachment, after deleting every record that alert box is displayed.
    If i immediately click OK on the alert box, then this problem is happening.
    If i leave the alert box without clicking the OK button, say for 5 seconds it is then reloading the grid fetching 10 records on the page which is the desired output.

Similar Threads

  1. Replies: 0
    Last Post: 12 Feb 2011, 4:38 AM
  2. Grid panel with JSON store | loading problem
    By waqasrazzaq in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 29 Dec 2010, 5:24 AM
  3. store loading problem..
    By nmohan.025 in forum Community Discussion
    Replies: 1
    Last Post: 6 Oct 2010, 12:18 AM
  4. Problem Loading data to store
    By pferril in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 21 Aug 2009, 4:51 AM
  5. Multiple store loading problem
    By deanoj in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 28 Apr 2008, 2:14 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •