cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting a Dynamic Table

Former Member
0 Kudos

We love the TableSorter class, it works great.

Now we want to sort a dynamic table and are having issues with it. Has anyone successfully used the TableSorter class with a dynamically generated table and if so, what did you do differently than with a static table?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Tom, TableSorter takes IWDTable as constructor parameter and it doesn`t matter whether it is statically or dynamically defined table.

Former Member
0 Kudos

Here's the issue, we have a static node and are adding attributes to the node dynamically. Then we dynamically create columns and bind them dynamically.

Then we create the TableSorter class.

The view setups properly with the sorting icons, but when we click them they just disappear and no sorting happens.

former_member182372
Active Contributor
0 Kudos

Tom, post code from wdmodifyview and sort action handler.

Former Member
0 Kudos

Hi,

I had a smiliar issue.

I am solving it by having the table dynamically created in on block.

And adding the new table sorter in the second block.

If you do two things in one block , it won't work.

Your code will be something like that:

in domodiftview :

if (firsttime){

construct dynamic table

prepare sorting fieldnames}

if (firsttime){

prepare the tabelsorter with the sort list

}

Hope this help.

yung siu wai

Former Member
0 Kudos

Sounds more like Voodoo

Armin

Former Member
0 Kudos

Here's what we have:

A context node named PDMTable. It is singleton, Cardinality 0..n, Selection 0..n. It has no attributes as they are created and added at runtime.

We have a table named SpecDetailTable1. It has it's dataSource as PDMTable. There are no columns as they are created and bound to the dynamic attributes at runtime...

We have a context attribute named TableSorter_SpecDetailsTable of type TableSorter.

In our wdDoModify we do:

if (firstTime) {

....

IWDTable PDMtable1 = (IWDTable) view.getElement("SpecDetailTable1");

wdContext.currentContextElement().setTableSorter_SpecDetailsTable(

new TableSorter(PDMtable1,wdThis.wdGetSortSpecDetailsTableAction(),null));

}

Then our Sort action handler is SortSpecDetailsTable:

try {

wdContext.currentContextElement().getTableSorter_SpecDetailsTable().sort(wdEvent, wdContext.nodePDMTable());

wdContext.nodePDMTable().setLeadSelection(0);

}

catch (Exception e) {

}

What we get is a filled table (works fine) with the sorting icons. Once we click on an icon (up or down) there is no sorting and the sorting icons for that column disappear.

Any help would be appreciated.

former_member182372
Active Contributor
0 Kudos

Tom, major part of the table sorter logic is in the TableSorter class constructor. And you are actuall instantiating table sorter class "on" empty table. So every time you change the "content" of table (add or remove columns for example) you have to recreate TableSorter class and pass modified table instance.

Former Member
0 Kudos

I think we may have found the problem. It looks like the developer is first creating the TableSorter and binding it to the context element and THEN he creates the table columns and binds them. We're going to move the TableSorter constructor/binding code to AFTER the table column creation/binding code and se what that does.

I'll post back should this fix the problem.

Former Member
0 Kudos

Yes this was the issue. Once we moved the code block it worked just fine.

Thank you.

Answers (0)