[ 2 posts ]

bible

  • Username: DazzlingBeing
  • Joined: Sun Jun 24, 2012 8:35 pm
  • Posts: 6
  • Offline
  • Profile

Why when operate DataTable,table body's Node changed

Post Posted: Sun Jun 24, 2012 8:47 pm
+0-
I create a DataTable,then visit a cell. for some reason I add a row in table, then visit that cell again.Finally, I find this Node is diffrent from the previous although it in the same Model.

example:
var table = Y.DataTable();
var td1 = table.getCell([0,0]);
table.addRow(...); // I am sure this row added at last.
//without addRow,there can be another operation,like table.sort(),table.removeRow,table.addColumn() etc.
var td2 = table.getCell([0,0]);
alert(td1==td2); //false.

Actually, td1 and td2 are the same cell in table, just after operation, td1 was replaced by td2.I want to know why is that.(No table.synUI() excute except on table's init at first)

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 511
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Why when operate DataTable,table body's Node changed

Post Posted: Mon Jun 25, 2012 9:47 am
+0-
DataTable currently rerenders the entire table body when any change to the data occurs. It was a compromise solution to allow the refactor to make it into the 3.5.0 timeframe. Here's a patch that will preserve existing rows:

https://gist.github.com/2295032
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum