Opened 13 years ago
Closed 13 years ago
#2522 closed defect (wontfix)
FilteringTable: cannot completely recreate widget metadata and data
Reported by: | Dan Dascalescu | Owned by: | Tom Trenka |
---|---|---|---|
Priority: | high | Milestone: | 1.0 |
Component: | Widgets | Version: | 0.4.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When a FilteringTable? is created from inside the "load" callback of a dojo.io.bind and populated with JSON data, there are 4 problems with the instantiated widget (code below):
- The data in the first JSON request populates the table OK, but the data in subsequent requests is shown in the table twice in each row: instead of (foo, bar, baz), the table displays (foo, bar, baz, foo, bar, baz).
- Calling clearData(), before setting up the columns and calling store.setData(), prevents the headers from displaying.
- Calling g.columns = [] after creating the widget and before setData() avoids the data duplication issue at 1., but this should not be necessary, since the widget is newly created and allegedly empty.
- Another issue I reproduced only with server-side code was that after the
second request, sorting by clicking table headers threw an exception "o has no properties".
Nabble link to e-mail thread for reference: http://www.nabble.com/FilteringTable.clearData%28%29-wipes-out-my-columns%21-tf3245419.html#a9176014 The code is (highlighted) at http://privatepaste.com/bfaN4Qiv9d and below.
Hope that helps, Dan Dascalescu
function populateTable(){
dojo.io.bind({
url: '/translations/search?output=json',
/* JSON data returned by the server for every request: {
"columns" : {
"id" : "Number", "source" : "String", "language" : "String", "target" : "String",
}, "items" : [
{
"source" : "View Contacts", "target" : "Kontakte anzeigen", "language" : "de", "id" : 0
}, {
"source" : "%s's Contacts", "target" : "Kontakte von %s", "language" : "de", "id" : 1
},
]
} */
handler: function(type, data, evt) {
if(type == "load"){
var g = dojo.widget.createWidget(
"dojo:FilteringTable", {valueField: "id", alternateRows: true, multiple: true, maxSortable: 1}, dojo.byId("grid")
); g.store.clearData(); <-- BUG #1: column headers will never be rendered if this is called
g is created each time populateTable() is called, but the 2nd and subsequent calls to populateTable() show the set of columns duplicated, i.e. columns 1..4, 1..4 if the next line is commented g.columns = []; this prevents the issue above with the columns becoming duplicated after the first call for (var name in data.columns) {
g.columns.push(g.createMetaData({field: name, dataType: data.columns[name]}));
} g.store.setData(data.items);
} else if(type == "error"){
alert("Error: " + data.message);
} else {
alert("Unkown handler type: " + type);
}
}, mimetype: "text/json", content: {
'q': dojo.byId('q').value,
}, changeURL: 'q=' + dojo.byId('q').value
});
}
<table valueField="id" class="grid" id="grid"></table>
Attachments (1)
Change History (4)
Changed 13 years ago by
Attachment: | Filtering_table_bugs.js added |
---|
comment:1 Changed 13 years ago by
Component: | General → Widgets |
---|
comment:2 Changed 13 years ago by
Summary: | Various issues with FilteringTables created in dojo.io.bind callback functions → FilteringTable: cannot completely recreate widget metadata and data |
---|
comment:3 Changed 13 years ago by
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is all being redone for the new Table widget, which operates via dojo.data
Code snippet to reproduce FilteringTable? bugs