Results 1 to 3 of 3

Thread: Store replace elements

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    23
    Vote Rating
    0
      0  

    Default Unanswered: Store replace elements

    Hello
    How i Can replace 2 elements in store. I have such list {1,2,3,4,5} I want to replace 1 with 3 to have {3,2,1,4,5}.
    Thanks

  2. #2
    Sencha User
    Join Date
    Jul 2013
    Posts
    23
    Vote Rating
    0
      0  

    Default

    My model class implements TreeNode<Model>,
    I have declared method swap which swaps 2 objects.

    Code:
    	public void swapChildren(int firstIndex, int secondIndex){
    		Collections.swap(children, firstIndex, secondIndex);
    	}
    I don't know how to notify tree to refresh view.
    I tried to store.fireEvent , commit Changes, update(parent object) but it doesn't work. Can Anyone help ?

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109
    Vote Rating
    93
      0  

    Default

    Instead of swapping on the child list (which won't actually change the order of the items in the store itself), remove each item and re-insert it where it belongs using the store methods. What is the `children` list you are swapping in that method? Assuming you are getting that by requesting treeStore.getChildren(parent), instead remove both of those children from the parent, then insert them where they belong.

Posting Permissions

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