cancel
Showing results for 
Search instead for 
Did you mean: 

Get the id or name table by pressing TableSort

Former Member
0 Kudos

Hello all,

We have two tables in a single iView. The event TableSort working perfectly for a table. But we want to be independent of each table. It just need to know the table that we have pressed to classify.

Copying <wdContext.currentContextElement().getTableSorter()> in expressions, show a node table = Table, which has an id attribute to the table, in our case Table2. Just knowing the press table, I can do an if statement and run the classification for the corresponding table.

Any idea?

Best Regards,

Jennifer Lohan.

Accepted Solutions (1)

Accepted Solutions (1)

sanyev
Active Participant
0 Kudos

Hi Jennifer,

I did not understand your question. Do you want to enable sorting on both the tables?

If so create two separate actions one for each table. And create two instances of the table sorter class.

if (firstTime) {
		  IWDTable table = (IWDTable) view.getElement("Table");
                  IWDTable table2 = (IWDTable) view.getElement("Table2");
		  wdContext.currentContextElement().setTableSorter(
			new TableSorter(table, wdThis.wdGetSortAction(), null));
                  wdContext.currentContextElement().setTableSorter2(
			new TableSorter(table2, wdThis.wdGetSortAction2(), null));               
	}

In your onAction implementation get the tableSorter instance for the appropriate table.

If you have a different requirement. Please explain it a little more clearly.

Regards,

Sanyev

Former Member
0 Kudos

Hello Sanyev,

my problem is in onAction. How to differentiate between the TableSort of Table1 and the TableSort of Table2?

The code in onActionSort is:

wdContext.currentContextElement().getTableSorter().sort(wdEvent, wdContext.nodeGeneraldataOutput1());

wdContext.currentContextElement().getTableSorter().sort(wdEvent, wdContext.nodeGeneraldataOutput2());

The way I am looking for is, if I press a sort in Table1, the first line is executed, and if I press the sort in Table2, the second line of code is executed.

How do I know which table is to be pressed to use the sentence "IF"?

I hope to have explained well.

Best Regards,

Jennifer Lohan.

sanyev
Active Participant
0 Kudos

Hi Jennifer,

You still will have to user two different action for sort on the table. I understand that you want to use the same sort action and then call the sort in the Table sorter class passing the right node.

While you initialize the TableSorter class you are passing the table view element to the TableSorter class. It internally stores the Table UI element for extracting the table columns. So first of all you need two instance of TableSorter class, one for each table. This is mandatory.

If you see the implementation code in onSort action handler of the Table, you are also passing a wdEvent to the sort method of the TableSorter class. The wdEvent is used to extract the columnID and sortDirection from the column that you clicked. These are different for different table.

So as i have mentioned in the post before, you will have to use two instances of the TableSorter class and two separate sort action handler. This is the only way.

Regards,

Sanyev

Former Member
0 Kudos

Hi Sanyev,

my problem was solved, thank you very much.

If I help someone mentioned methods:

public static void wdDoModifyView(IPrivateView wdThis, IPrivateView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
if (firstTime) 
	{
	IWDTable table1 = (IWDTable) view.getElement("Table1");
	IWDTable table2 = (IWDTable) view.getElement("Table2");
	wdContext.currentContextElement().setTableSorter( new TableSorter(table1, wdThis.wdGetSortAction(), null));
	wdContext.currentContextElement().setTableSorter2( new TableSorter(table2, wdThis.wdGetSort2Action(), null));
	}
}

public void onActionSort(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
       wdContext.currentContextElement().getTableSorter().sort(wdEvent,wdContext.nodePending_Request2());
}

public void onActionSort2(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{ 
       wdContext.currentContextElement().getTableSorter2().sort(wdEvent,wdContext.nodePending_Request1());
}

Best Regards,

Jennifer Lohan.

Answers (0)