1. #1
    Sencha User
    Join Date
    Jan 2012
    Location
    San Mateo, CA
    Posts
    46
    Answers
    7
    Vote Rating
    0
    neurodon is on a distinguished road

      0  

    Default Unanswered: Refreshing a Treepanel

    Unanswered: Refreshing a Treepanel


    I'm trying to refresh a TreePanel so any records updated in the store will sync:

    Code:
    panel.getStore().sync();
    panel.getStore().load();
    panel.getView().refresh();
    My TreeStore has 'clearOnLoad' set to false.

    The behavior is erratic with this.. what happens is the updated row is successfully added.. but one of the existing rows is duplicated in the view.

    For example (this is a threaded comment system):

    Original store/view:

    [[
    Comment1
    Comment2
    Comment3
    Comment4
    ]]

    <User adds comment to the store: CommentNEW>
    <Application triggers store update - sync,load,refresh>

    The TreeView now displays:
    [[
    Comment1
    Comment2
    Comment3
    Comment4
    CommentNEW
    Comment1
    ]]

    Any thoughts?

  2. #2
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Answers
    20
    Vote Rating
    18
    James Goddard will become famous soon enough James Goddard will become famous soon enough

      0  

    Default


    Check your id property and values.

    Comment 1 cannot be duplicated in the tree unless both have different id's.

  3. #3
    Sencha User
    Join Date
    Jan 2012
    Location
    San Mateo, CA
    Posts
    46
    Answers
    7
    Vote Rating
    0
    neurodon is on a distinguished road

      0  

    Default


    Yeah, thats got to be it.. I'm getting an exception whenever the "error" load happens.

    Uncaught TypeError: Cannot read property 'internalId' of undefined

    My model has 'internalId' set to my 'eventid' property - which is a GUID style string. I've checked the output from the server.. and all the properties are unique. There is something getting lost in translation between tree loads.

    If I can find the source of this exception, I can solve the ID problem... hmm..

    P.S: Here is a stack trace of the error.

    stacktrace.png

  4. #4
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    St Louis,MO
    Posts
    267
    Answers
    20
    Vote Rating
    18
    James Goddard will become famous soon enough James Goddard will become famous soon enough

      0  

    Default


    .. and all the properties are unique
    Not exactly sure what you are saying here but if what you are saying is that the ID is always unique, this will cause your issue.

    For example:
    in the initial load Comment 1 has an id of xxxx, Commment 2, yyyy, etc
    on the reload Comment 1 has an id of qqqq.

    As far as the store is concerned you have 2 records with the name "Comment 1" because xxxx != qqqq.

    Comment 1 needs to ALWAYS have the same id, which must be unique to other records.

Thread Participants: 1