cancel
Showing results for 
Search instead for 
Did you mean: 

how to realize Table Popup menu of NW 2004s ?

Former Member
0 Kudos

i need mice right-click menu function in my table in my web dynpro project.

this come true in NW 2004s.but i cann't get any clues on Table Popup menu.

especial for this:

assume i have N column(TextView) in my table,when some row is OnLeadSelect,right click pop up a menu.

thank in advance!

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi,

Just discussed:

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski .

first thank u reply.

i met a little matter as Bala Krishnan 'reply post.as following:

-


<b>1.) Create a table and bind its dataSource property to the suitabel node.

2.) Insert a column with table cell editor as "TextView" and "<u>CellVariant" as "TablePopinToggleCell</u>"(<u>so sorry i don't understand what's it means.can u explain it to me?i cann't find any CellVariant. ).</u>

.......

</b>----


former_member182372
Active Contributor
0 Kudos

Bala Krishnan was talking about Popin, not Popup. Read my post(which is marked as "Solved problem") and comments on this.

Former Member
0 Kudos

sorry Maksim Rashchynski ,are u refer to this reply post?

-


<u>Hi Tony,

Check http://help.sap.com/saphelp_nw2004s/helpdata/en/de/416d42ab7fd142e10000000a1550b0/frameset.htm

In a table, popup menus can be used when a UI element is used as a cell editor and when the UI element can be assigned a popup menu.

Select appropriate cell editor, right click, select "Insert menu".

To get cell and row you can through parameter mapping of OnLeadSelect event (String col - The ID of the selected column. int row - The zero based index of the selected row (i.e. the one the user has just chosen). Note that, depending on the table's selection change behaviour, this might not yet be the data source's current lead selection.This parameter is replaced by the String based "newRowElement" parameter for hierarchical tables where a row cannot be adequately represented by an index, but only by its associated node element. In general, it is deprecated and should be avoided in future development. Declare an action and event handler parameter of type IWDNodeElement (or one of your own element classes) along with a suitable parameter mapping; then the path will be automagically transformed into a node element instance which you can ask for its index.)

Best regards, Maksim Rashchynski.</u>----


but this is only realize some column right-click menu in a table?

you know it's impossible to give every column to set the same config menu one by one.especailly i have at least 80 colums to display in the table.

can i config a right-click menu for a total row in the table?you know,there are the same menu items for some row in table.

former_member182372
Active Contributor
0 Kudos

In this case you can iterate through your cell editors and insert popups dynamicaly in wdDoModifyView method.

Former Member
0 Kudos

HI,Maksim Rashchynski

can u tell me more clearly about that?of course the code example is better.

cann't we set the one total row menu in a table instead of set every column menu to combine one row?

former_member182372
Active Contributor
0 Kudos

Hi,

Let`s assume that your table id is "Table" and all cell editors are text views.

In wdDoModifyView put something like this:


    if(!firstTime) return;

    IWDAction action = wdThis.wdGetActionAction();
    IWDMenu menu = (IWDMenu)view.createElement(IWDMenu.class, null);
	IWDMenuActionItem item = (IWDMenuActionItem)view.createElement(IWDMenuActionItem.class, null);
	item.setOnAction(action);
	item.setText("Item text");
	menu.addItem(item);

    IWDTable table = (IWDTable) view.getElement("table");
	Iterator groupedColumns = table.iterateGroupedColumns();
	while (groupedColumns.hasNext()) {
		IWDTableColumn element = (IWDTableColumn) groupedColumns.next();
		((IWDTextView)element.getTableCellEditor()).setMenu(menu);
	}

Pay attention that this code is from scratch and not tested as I don`t have access to 2004`s system now.

Best regards, Maksim Rashchynski.

<old>As we can not create menu items on the runtime you need a small trick: create text view, bind a menu (id="Menu") with menu items to it (through "Insert menu") and set visibility property of text view to none.

</old>

Sorry for confusing.

Message was edited by: Maksim Rashchynski

Former Member
0 Kudos

Maksim,

What do you mean with "As we can not create menu items on the runtime"? Of course you can. But with the static menus, you cannot create/modify menus after the event for opening the menu.

Armin

Former Member
0 Kudos

If I understand your requirement correctly, you have a table with many columns and you want to have a "context" menu for a single row only?

If that's correct, I would not recommend this kind of menu. Perhaps you can use toolbar items instead.

The NW04s menus are not usable as dynamic context menus, they are only static menus where the content is known beforehand. Because they are rendered inside the view UI tree, you should use them sparingly inside tables and trees.

Nevertheless, you can get a certain degree of variation by binding the menu item properties to attributes inside the table data source.

Armin

Former Member
0 Kudos

HI,Maksim Rashchynski

I done it as u said,

.....

<b>IWDTable table = (IWDTable) view.getElement("table");

Iterator groupedColumns = table.iterateGroupedColumns();

<u>//debug it step by step.but i cann't iterator the total column.i modified it as :Iterator groupedColumns = table.iterateColumns();that is ok.</u>while (groupedColumns.hasNext()) { ....

}</b>

former_member182372
Active Contributor
0 Kudos

Hi,

Does it solve your problem or not?

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

hi,Maksim Rashchynski

i still don't solved it.

your coder cann't be executed correctly.

....

IWDTable table = (IWDTable) view.getElement("table");

Iterator groupedColumns = table.iterateGroupedColumns();

<b>//debug step by step.it cann't iterator the column number(it means the sentence inclued in while(){.....} cann't be executed),if i changed it to:<u>Iterator groupedColumns = table.iterateColumns();</u>,the following sentence<u>:((IWDTextView)element.getTableCellEditor()).setMenu(menu);</u> throws exception:<i>java.lang.ClassCastException</i></b>

while (groupedColumns.hasNext()) {

IWDTableColumn element = (IWDTableColumn)groupedColumns.next();

((IWDTextView)element.getTableCellEditor()).setMenu(menu); }

former_member182372
Active Contributor
0 Kudos

Hi,

What do you have as cell editors? This example will work only in case all your cell editors are text view`s.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

if i have some column is not textView(such as checkbox),any problem?

former_member182372
Active Contributor
0 Kudos

...
IWDTableColumn element = (IWDTableColumn) groupedColumns.next();		
if(element.getTableCellEditor() instanceof IWDTextView) {
((IWDTextView)element.getTableCellEditor()).setMenu(menu);
}
...
Former Member
0 Kudos

hi,Maksim Rashchynski

are u sure following code is ok?

IWDTable table = (IWDTable) view.getElement("TblDeal");

<b>Iterator groupedColumns = table.iterateGroupedColumns();</b>

<u>while (groupedColumns.hasNext()) {

IWDTableColumn element = (IWDTableColumn) groupedColumns.next();

if(element.getTableCellEditor() instanceof IWDTextView) {

((IWDTextView) element.getTableCellEditor()).setMenu(menu);

}

}</u>

-


if yes,the underline code will skip .this is to say.it cann't iterator the column item.

if i modified it to:

<b>Iterator groupedColumns = table.iterateColumns();</b>

following code is occured exception after the first textView column iterator:

<b>((IWDTextView) element.getTableCellEditor()).setMenu(menu);</b> error as following:

<i>java.lang.IllegalStateException: Aggregation parent of view element with id="_2" is already set.</i>

.......

former_member182372
Active Contributor
0 Kudos

Well, seems like menu can be aggregated by only one element. Then you have to move

IWDAction action = wdThis.wdGetActionAction();   
 IWDMenu menu = (IWDMenu)view.createElement(IWDMenu.class, null);	
IWDMenuActionItem item = (IWDMenuActionItem)view.createElement(IWDMenuActionItem.class, null);
item.setOnAction(action);
item.setText("Item text");
menu.addItem(item);

inside while block.

Former Member
0 Kudos

hi,Maksim Rashchynski

now i successed to get get the popu menu as u said.but i have to modified a little :

<b>Iterator groupedColumns = table.iterateColumns();</b>

finally i found it's not really suit to me after i got the click menu function.

firstly,i just need the menu function on the Lead Selection row in some table.but now we get the every row menu in my table,that's a waste of software performance!

secondly,if the length of some column is bigger than the length of some TextView's Text ,you cann't got the click menu when u click on the blank space column.

in fact.i need the mice right-click menu function in table.or similar to it.can u have any other ideas about that?

thanks a lot

points will be reward of you.

Former Member
0 Kudos

Please see my remarks concerning the restrictions of this kind of menus. Perhaps a toolbar would better suit your needs here.

Real context menus will be available with the next major Web Dynpro release.

Another remark: Don't use "Columns" and "GroupedColum" together in a table. The "Columns" aggregation is deprecated and has been replaced by the "GroupedColumns" aggregation. Mixing both will lead to unwanted effects.

Armin

Former Member
0 Kudos

hehe......thanks finally!

Answers (0)