« Return to Thread: Clearting Out and re-populating filteringtable

Re: Clearting Out and re-populating filteringtable

by KevinTrainer :: Rate this Message:

Reply to Author | View in Thread

I had the same issue.  For the app I am developing, the user is allowed to choose a query and I am displaying the results in a filtering table.  What I ended up doing was destroying the existing Filtering table, which deletes the DOM node for the table.  The I programatically created a new table node, created a new FilteringTable, populated the new columns and data then appended the table node to a content div.  This seems to work well.  


......................................

            var testColumns = tableDat.headerInfo
            var testData    = tableDat.rowInfo
           
            if(filteringTable)
              filteringTable.destroy()
         
           table=document.createElement("table");  
           table.className="data";
             
          filteringTable = dojo.widget.createWidget("dojo:FilteringTable",{valueField: "myId"},table);
     
          for (var x = 0; x<testColumns.length; x++) {
        filteringTable.columns.push(filteringTable.createMetaData(testColumns[x]));
          }
                       
                       
        filteringTable.store.setData(testData);

       document.getElementById('content').appendChild(table);
......................................

However I am a newbie when it comes to the dojo toolkit so if there is a better way Id like to know about it.

By the way, I think the tool kit is fantastic!


MW wrote:
Hi, just a quick question - if i want to re-use a filteringtable widget with a different dataset [ potentially different columns and rows ] - how do i clear out the columns ?

I've tried filteringtable.store.clearData();

but this throws an error -> jojo.html.setClass() failed [TypeError: node has no properties, file: http://auroradev.net/dojo/dojo.js, line: 4679]

code fragment below:-

        populate: function(data){
                var rows = data["rows"];
                var columns = data["columns"];
                this.fTable.store.clearData(); // if removed, then columns don't reset - left in produces error
                this.fTable.valueField = data["key"];
                for (var x = 0; x<columns.length; x++) {
                        this.fTable.columns.push(this.fTable.createMetaData(columns[x]));
                }
                this.fTable.store.setData(rows);
        }

any help much appreciated.

 « Return to Thread: Clearting Out and re-populating filteringtable