cancel
Showing results for 
Search instead for 
Did you mean: 

how to rearrange the table column order in WD?

Former Member
0 Kudos

as title as said.how to rearrange the table column order by some event.

any clues will be appreciate!

Accepted Solutions (1)

Accepted Solutions (1)

venkatakalyan_karanam
Active Contributor
0 Kudos

Hi

Take a boolean Attr in context,set the value true in the Action where you want to swap the columns.

In wdModifyMethod get the value of that attr using wdContext object ref.

Swap the table columns

Again set the Attr value to false.

This is the one way of acheiving that

regards

kalyan

Answers (1)

Answers (1)

former_member182372
Active Contributor
0 Kudos

<a href="https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/clientserver/uielib/standard/api/IWDTable.html#swapGroupedColumns(int, int)">IWDTable.swapGroupedColumns(int, int)</a>

Former Member
0 Kudos

sir.in fact i can do it as u said in

 wdDoModifyView(..){
      if(firstTime){
		IWDTable tbl = (IWDTable) view.getElement("TableTest");
		tbl.swapGroupedColumns(1,2);
    }

}

but now i wanna rearrange them by some other event(not in wdDoModifyView method).i cann't got the<b> view Object</b>.how to got it...

  IWDTable tbl = (IWDTable) view.getElement("TableTest");

former_member186016
Active Contributor
0 Kudos

Hi,

In the other event method did you tried refreshing the view. I think then the wdDoModifyView(...) will be called. Then you swap as you are doing in above code snippet.

Also you can fire inbound plug to the same view. In that case also the view will be refreshed and WdDoModifyView(...) should be called.

Regards,

Ashwani Kr Sharma

Former Member
0 Kudos

sir,

i have another confusing for another.

e.g: i have five columns(A,B,C,D,E in order) in one table.i wanna put the first column(A) to the last position(order by B,C,D,E,A ),as u said,i must do four steps as following?

A->B -


>

tbl.swapGroupedColumns(0,1);

B->C,----


>

tbl.swapGroupedColumns(1,2);

C->D,----


>

tbl.swapGroupedColumns(2,3);

D->E -


>

tbl.swapGroupedColumns(3,4);

i have any else ways to realized it once?

Former Member
0 Kudos

Wing,

Try the following (should work):


IWDTableColumn col = table.removeColumn(0);
table.addColumn(col);

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

sir,

i met on some new problem.

any ways to resolve back the original column order after rearrange table' column?

e.g.: have four columns(A,B,C,D in order),after rearranged it(be rearranged by B,C,D,A).i wanna back the original statue(be arranged by A,B,C,D).

Former Member
0 Kudos

Hi,

Let's say your column order is initially [A,B,C,D]. If you want to rearrange it to [B,C,D,A], you can use (as suggested by Valery)

IWDTableColumn col = table.removeColumn(0);
table.addColumn(col);

Now if you have to go back to the original column settings, then you can use

IWDTableColumn col = table.removeColumn(3);
table.addColumn(col,0);

Regards,

Satyajit.

Former Member
0 Kudos

sorry for my unclearly expression!

i just made a simpliest example as aboving.

in fact we should often have such requirement as following:

many columns in a table control needing to be rearrange,

there are two arrangements(the <b>two</b> and the <b>three</b> status as following said) after rearranged.

So it involved three status:

-


one: the original arrangement.

<b>two</b>: rearranged from one status

<b>three</b> : <b>(i)</b> rearranged from one status ;

(ii) rearranged from two status ;***********(<i>at here i hope i can got the original arrangement status.that i can invoke the same function as item <b>(i)</b> do.</i>)

Former Member
0 Kudos

Hi ,

I would suggest you to get the IDs of all columns and store it in an arraylist.

If the order needs to be changed, change the order of IDs in the arraylist.

While adding the columns to the table, read the value from the arraylist

//loop through array with index "indx"
table.addColumn(arraylist.get(indx))

By using an arraylist for storing order and reading the values from the arraylist.. you can re-arrange by pushing the values in the arraylist in that particular order .

Does it suit your requirement ?

regards

Bharathwaj