Results 1 to 6 of 6

Thread: Calling GridPanel.store.load, I lose selected item

  1. #1

    Default Calling GridPanel.store.load, I lose selected item

    I have a multi panel application. A grid in one panel and a form in one panel.
    When I update some data via a form, I want to update the grid with this information.
    So I call GridPanel.store.load() which refreshes the grid.
    However, now I've lost my selected item. I would like to have the previously selected item remain selected.

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    Before you reload the store, keep track of any items of selected. Once the load has completed, go through and reselect the appropriate rows.

  3. #3

    Default

    This is not working. Can someone point me in the right direction. Thanks
    Code:
    // Store the selected item
    var oItems = grid.selModel.getSelections();
    	
    // Refresh the customer grid
    grid.store.load();
    	
    // Restore the selected item
    grid.selModel.selectRecords(oItems);

  4. #4

    Default

    I think I see what is happening. The refresh (grid.store.load) is happening asynchronously and is occurring after the selectRecords()

  5. #5

    Default

    Tried with a callback and still having trouble
    I made a global variable for the items (g_items) just until I get the code working.

    Code:
    g_items = grid.selModel.getSelections();
    	
    // Refresh the customer grid
    grid_customer.store.load({
       callback: function (){
          //grid.selModel.selectAll(); // This works
          grid.selModel.selectRecords(g_items, false); // not working
          //grid.selModel.selectRecords([g_items], false); // not working
          //grid.selModel.selectRecords([g_items[0]], false); // not working
       }
    });

  6. #6

    Default

    When I changed to a singleSelect selection model,
    Code:
    sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
    the following line of code worked:
    Code:
    g_items = grid.selModel.getSelections();
    	
    // Refresh the customer grid
    grid_customer.store.load({
       callback: function (){
          grid_customer.selModel.selectRecords(g_items[0], false);	
          grid_customer.selModel.selectAll();
       }
    });

Posting Permissions

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