cancel
Showing results for 
Search instead for 
Did you mean: 

Setting focus to a table row

Former Member
0 Kudos

Hi,

I am trying to set the focus in a table to a new row which I have created(Always created at the end). Im using the following line :

allocationnode.addElement(allocationele);

allocationnode.moveLast();

But its not working. A new row is getting created. But the focus doesnt change

I also tried:

allocationnode.setLeadSelection(size-1);

But in vain.

Can anyone tell me what the problem could be?

Thanks in Advance,

Reena

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Reena,

Write this code after you add the element to the table.

int i = allocationnode.size() - 1;
allocationnode.setLeadSelection(i);

This will highlight the lastly added row in the table if the selection mode in the table is "auto".

Bala

Message was edited by: Bala Krishnan

Former Member
0 Kudos

Hi Bala,

I tried your code. But its not helping. Dont know where I am going wrong. Here is my code snippet.

allocationnode.addElement(allocationele);

int i = allocationnode.size() - 1;

allocationnode.setLeadSelection(i);

Any other pointers?

Thanks in Advance,

Reena

Former Member
0 Kudos

Reena,

Try this:

allocationnode.addElement(allocationele);

allocationnode.setLeadSelection( allocationele.index() );

VS

Former Member
0 Kudos

Armin, I tried using your code. Its giving me an error.

Valery,

No. Not working.

Any settings to be done in the node properties?

I mean cardinality, singleton value, etc. Will these values make a difference?

Thanks in Advance,

Reena

Former Member
0 Kudos

Reena,

Could you clarify "not working"?

If row is not highlighted, then it is one problem, when table does not scroll content up to inserted row, then you need to synchronize "view port" -- and it is different issue.

VS

Former Member
0 Kudos

Hi Valery,

"If row is not highlighted, then it is one problem...... "

I am not able to identify if a row is higlighted or not.

The table in my application currently has 20 rows, of which only 5 are visible ( I have set visibleRowCount = 5 ). The selectMode of my table is 'None'. ( I donot want to use 'Auto' ).

Now, I have called an action on the click of a button, in order to insert an empty row into the table and I have written the code to add and move in this method.

When I click the button, I see the number of rows changing from 20 to 21. But the table still shows the first five rows. I want the focus to shift to the last row.

Thanks in Advance,

Reena

Former Member
0 Kudos

Reena,

Then if fact you have problem #2 -- view port synchronization.

1. Bind "firstVisibleRow" table property to some integer attribute in view context, say FirstRow.

2. In action handler, after all suggested code add line:

wdContext.currentContextElement.setFirstRow( node.size() - 5 );

VS

Former Member
0 Kudos

Hi Valery,

Its working fine now. Full points to you.

Thanks a Ton.

Regards,

Reena

Answers (1)

Answers (1)

Former Member
0 Kudos

Try method IWDViewController.requestFocus(IWDNodeElement, IWDAttributeInfo)

https://media.sdn.sap.com/javadocs/NW04/SPS15/wd/com/sap/tc/webdynpro/progmodel/api/IWDViewControlle...

Pass the node element corresponding to the new table row and the attribute (info) shown in the table column.

Armin