Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#1379 closed defect (fixed)

Removing an object from store kills FilteredTable

Reported by: me@… Owned by: Tom Trenka
Priority: high Milestone:
Component: Widgets Version: 0.4
Keywords: Cc:
Blocked By: Blocking:

Description

Try running this HTML. Populate the JSON, then remove a row clicking the button. This is using dojo 31/8/2006. The failure as far as I can tell is here

dojo.event.connect(this.store, "onRemoveData", function(removedObject){ 832 var rows = self.domNode.tBodies[0].rows; 833 for(var i=0; i<rows.length; i++){ 834 if(self.getDataByRow(rows[i]) == removedObject.src){ 835 rows[i].parentNode.removeChild(rows[i]); 836 break; 837 } 838 } 839 self.render(); 840 });

self.getDataByRow(rows[i]) will not contain the row, so the DOM will not be updated to reflect the row removal in the store. Here is a page to reproduce it.

Thanks, Mike.

<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01 TransitionalEN"

"http://www.w3.org/TR/html4/loose.dtd">

<html> <head> <title>Filtering test</title> <script type="text/javascript">

var djConfig = {

isDebug: true ,debugAtAllCosts: true

};

</script> <script type="text/javascript" src="dojo.js"></script> <script type="text/javascript">

dojo.require("dojo.widget.FilteringTable?"); dojo.require("dojo.data.SimpleStore?"); dojo.hostenv.writeIncludes();

Array.prototype.oneOf = function() {

return this[Math.round(Math.random() * (this.length - 1))];

}

var theJSONData = []; var names = ["Fred",

"Jim", "Tom", "Mike", "Fred Again", "Tom Again", "Other name" ];

function remove(id) {

var store = dojo.widget.byId("fromJSONData").store; store.removeDataByKey(id)

} for (var i = 0; i < 5; i++) {

var o = {

Id:i, name:names.oneOf()

}; theJSONData.push(o);

}

function populateTable() {

var w = dojo.widget.byId("fromJSONData"); if (w.store.get().length > 0) {

alert("you already pressed this button :)"); return;

} w.store.setData(theJSONData);

}

</script> </head> <body> <h2>Filtering Table, populated from JSON data</h2> <input type="button" value="Click to populate using JSON data" onclick="populateTable();"/><br/> <input type="button" value="Click to remove some JSON data" onclick="remove(0);"/><br/>

<table dojoType="filteringTable" id="fromJSONData"

maxSelect="0" alternateRows="true" cellpadding="0" cellspacing="0" border="0">

<thead>

<tr>

<th field="Id" dataType="String">ID</th> <th field="name" dataType="String">Name</th>

</tr>

</thead>

</table>

</body> </html>

Change History (4)

comment:1 Changed 13 years ago by dylan

Milestone: 0.4
Owner: changed from bill to Tom Trenka

comment:2 Changed 13 years ago by Tom Trenka

Version: 0.30.4

comment:3 Changed 13 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

(In [5502]) Fixes #1379; fire the onRemoveData event *before* actually removing the data.

comment:4 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.