Opened 6 years ago

Closed 4 years ago

#17376 closed defect (invalid)

Observable behaviour with paged data. Observe() callbacks fired incorrectly.

Reported by: neville1355 Owned by: neville1355
Priority: undecided Milestone: 1.11
Component: Data Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

See the community post here: http://dojo-toolkit.33424.n3.nabble.com/Observable-doesn-t-work-properly-on-paged-data-tp3998481.html

This problem manifested itself while using the OnDemandGrid? from http://dgrid.io

Basically, as I was modifying rows from the first page, they would jump to the end of the second page. This was due to the observe callback being called with a removedFrom = -1.

See the jsfiddle here demonstrating the core issue in Observable: http://jsfiddle.net/TmddB/

Change History (4)

comment:1 Changed 6 years ago by bill

Component: GeneralData
Owner: set to Kris Zyp

comment:2 Changed 5 years ago by bblain7

In line 114 of Observable.js in Dojo 1.9+ there is a conditional.

}else if(!options.start){
  // a new object
  insertedInto = store.defaultIndex || 0;
  resultsArray.splice(insertedInto, 0, changed);
}

A search on github produce only the single result for "defaultIndex". It would seem that insertedInto always defaults to 0 when options.start = -1.

Secondly, in the paging scenario given options.start would be equal to 10 so else if(!10) resolves to false. It doesn't appear that this conditional is meaningful. If it is removed for simply else the condition below will fire listeners correctly.

  • removedFrom is -1 for an add
...
  }else{
    // a new object
    insertedInto = 0;
    resultsArray.splice(insertedInto, 0, changed);
  }
}
if((removedFrom > -1 || insertedInto > -1) &&
(includeObjectUpdates || !queryExecutor || (removedFrom != insertedInto))){

  var copyListeners = listeners.slice();
  for(i = 0;listener = copyListeners[i]; i++){
    listener(changed || removedObject, removedFrom, insertedInto);
  }
}

comment:3 Changed 4 years ago by dylan

Milestone: tbd1.11
Owner: changed from Kris Zyp to neville1355
Status: newpending

I believe this was fixed (and certainly fixed for dgrid 0.4 and its switch to using dstore). Please reopen if still an issue.

comment:4 Changed 4 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.