Permalink
Browse files

When inserting a row, remove previously existing row if it existed el…

…sewhere
  • Loading branch information...
1 parent e24016f commit f7fe95b15eea650d1c7927eea219db639ace62bd @kriszyp committed Mar 15, 2012
Showing with 8 additions and 4 deletions.
  1. +5 −1 List.js
  2. +3 −3 test/Tree.html
View
@@ -452,7 +452,11 @@ function(arrayUtil, kernel, declare, listen, aspect, has, miscUtil, TouchScroll,
// Renders a single row in the grid
var id = this.id + "-row-" + ((this.store && this.store.getIdentity) ? this.store.getIdentity(object) : this._autoId++);
var row = byId(id);
- if(!row){
+ if(!row || // we must create a row if it doesn't exist, or if it previously belonged to a different container
+ (beforeNode && row.parentNode != beforeNode.parentNode)){
+ if(row){// if it existed elsewhere in the DOM, we will remove it, so we can recreate it
+ this.removeRow(row);
+ }
row = this.renderRow(object, options);
row.className = (row.className || "") + " ui-state-default dgrid-row " + (i% 2 == 1 ? oddClass : evenClass);
// get the row id for easy retrieval
View
@@ -78,8 +78,8 @@
item.name = "Europe Edit " + (++count);
testCountryStore.put(item);
});
- on(document.getElementById("move-italy-na"), "click", function(){
- var item = testCountryStore.get("IT");
+ on(document.getElementById("move-rome-na"), "click", function(){
+ var item = testCountryStore.get("Rome");
item.parent = "NA";
testCountryStore.put(item);
});
@@ -141,7 +141,7 @@ <h2>Lazy-loading tree grid, with store functionality</h2>
<button id="remove-country">Remove Greece</button>
<button id="delete">Delete Selected</button>
<button id="edit-continent">Edit Europe</button>
- <button id="move-italy-na">Move Italy to North America</button>
+ <button id="move-rome-na">Move Rome to North America</button>
<h2>Tree grid with checkbox selector to test select-all on children</h2>
<div id="treeSelector"></div>

0 comments on commit f7fe95b

Please sign in to comment.