Opened 13 years ago

Closed 13 years ago

#2304 closed defect (wontfix)

FilteringTable: column headers not displayed after reset plus column add

Reported by: paul@… Owned by: Tom Trenka
Priority: high Milestone:
Component: General Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:

Description

I am reusing a single FilteringTable? widget to display different table columns depending on the state of a drop-down elsewhere on the page. When the drop-down changes, I call FilteringTable?.reset(), then add the columns for the new value of the drop-down:

var mylocal = {
      tableColumns: {
          val1: [ { field: "foo" }, { field: "bar" } ],
          val2: [ {field: "baz" }, { field: "bam" } ]
      },
      update: function() {
        dojo.io.bind({
          formNode: dojo.byId('myForm'),
          load: function(type, data, evt) {
            filteringTable = dojo.widget.byId('filteringTable');
            dropDown = dojo.byId('dropDown');
    
            // recreate the columns
            filteringTable.reset();
            for (i in myLocal.tableColumns[dropDown.value]) {
              filteringTable.columns.push(filteringTable.createMetaData(myLocal.tableColumns[dropDown.value][i]));
            }
        
            // bind the data
            dojo.widget.byId('filteringTable').store.setData(eval(data));
          },
          error: function(type, error) {
            alert(dojo.errorToString(error));
          }
        });
    }
}
...
<table dojoType="FilteringTable" id="filteringTable"></table>

I found that when I switch the drop-down values, the proper columns are recreated, but the table header is missing. I tracked this down to the FilteringTable?.init() where it checks for a table head:

//	if there is no thead, create it now.
var head=this.domNode.getElementsByTagName("thead")[0];
if(head.getElementsByTagName("tr").length == 0){

Because I declare my table's dojoType, the first time init() is called, there are no tr elements, so all subsequent calls don't construct the proper tr/th elements. One fix (which I'm not convinced is best, mind you) is to explicitly clear out the head each time init() is called:

//	if there is no thead, create it now.
var head=this.domNode.getElementsByTagName("thead")[0];

while (head.firstChild) {
    dojo.dom.destroyNode(head.firstChild);
}

if(head.getElementsByTagName("tr").length == 0){

I will attach a modification of the "Programmatic FilteringTable? Test" that reproduces the issue.

Attachments (1)

test.html (2.4 KB) - added by paul@… 13 years ago.
modification of Programmatic FilteringTable? Test to reproduce bug

Download all attachments as: .zip

Change History (3)

Changed 13 years ago by paul@…

Attachment: test.html added

modification of Programmatic FilteringTable? Test to reproduce bug

comment:1 Changed 13 years ago by Tom Trenka

Owner: changed from anonymous to Tom Trenka

comment:2 Changed 13 years ago by Tom Trenka

Resolution: wontfix
Status: newclosed

This was by design; the widget was never meant to create a table on the fly for you, but to enable an existing table to have additional functionality (i.e. it is degradable).

Filtering.reset is there to reset data only, not meta-data (i.e. columns).

Won't fix.

Note: See TracTickets for help on using tickets.