marat-gainullin / platypus-js

Apache License 2.0
9 stars 9 forks source link

ModelGrid does not react on changes in data #81

Closed valeriy-maslov closed 8 years ago

valeriy-maslov commented 8 years ago

I provide screeshot for explanation. In this case I have ModelGrid component. It's data property is defined as teams array which contains only two elements at start. But if I try to push single object in this array and ModelGrid doesn't seem to be redrawed automaticly. Another strange thing is that calling redraw() from ModelGrid is actually takes no effect on this situation. New rows still stay invisible. So it doesn't seems to work at all. screenshot_20160531_140423

valeriy-maslov commented 8 years ago

UPD: By switching rows in left grid in my case grid at right half must be updated. There is some logic which destroys teams array and creates it again filled with new data meant to be displayed in right grid. At the start it's nothing, no any exceptions are thrown. No exceptions on adding new elements in array either. But when I try to switch it throws this.

pwc-0.js:1084 31.05.2016 14:36:12   SEVERE  Row index: 0, Row size: 0   
java.lang.IndexOutOfBoundsException: Row index: 0, Row size: 0
    at Unknown.Sxb(pwc-0.js)
    at Unknown.Yxb(pwc-0.js)
    at Unknown.$xb(pwc-0.js)
    at Unknown.gAc(pwc-0.js)
    at Unknown.zz(pwc-5.js)
    at Unknown.nA(pwc-5.js)
    at Unknown.mA(pwc-5.js)
    at Unknown.xy(pwc-5.js)
    at Unknown.yy(pwc-5.js)
    at Unknown.oC(pwc-5.js)
    at Unknown.xic(pwc-7.js)
    at Unknown.Ljc(pwc-7.js)
    at Unknown.bkc(pwc-7.js)
    at Unknown.eAb(pwc-0.js)
    at Unknown.Wzb(pwc-0.js)
    at Unknown.Ezb(pwc-0.js)
    at Unknown.Dzb(pwc-0.js)
    at Unknown.eval(pwc-0.js)
mfc @ pwc-0.js:1084Gfc @ pwc-0.js:1076Ffc @ pwc-0.js:850qLc @ pwc-0.js:410Hzb @ pwc-0.js:918eAb @ pwc-0.js:1011Wzb @ pwc-0.js:812Ezb @ pwc-0.js:818Dzb @ pwc-0.js:1028(anonymous function) @ pwc-0.js:958

I've traced this exception with chrome debugger so it happens after teams array build logic (btw it's always built correctly). The exception appears when grid starts to render data or doing another dark things hidden from my eyes =)

marat-gainullin commented 8 years ago

Fixed. ModelGrid.redraw() had a bad dependency on data driven events (either browser or Platypus.js ORM). Without such events, ModelGrid.redraw() was unable to redraw its rows.

It was all about Object.observe() support. It has disappeared from browsers and this dependency became obvious.

Now ModelGrid.redraw() doesn't need any events and completely redraws all rows of grid.

Available in nightly build