#1379 closed defect (fixed)
Removing an object from store kills FilteredTable
Reported by: | 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"
<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 15 years ago by
Milestone: | → 0.4 |
---|---|
Owner: | changed from bill to Tom Trenka |
comment:2 Changed 15 years ago by
Version: | 0.3 → 0.4 |
---|
comment:3 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [5502]) Fixes #1379; fire the onRemoveData event *before* actually removing the data.