cancel
Showing results for 
Search instead for 
Did you mean: 

Go to new Row in table

Former Member
0 Kudos

Hi all,

Well can anybody plz tell me how to go to new row in table control of webdynpro.Basically i want to use onEnter on Input field UI inside a table column so that it shud go to new row in the table .

Regards:

Hanif

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

answered

nikhil_bose
Active Contributor
0 Kudos

hi shaikh,

Let me first understand your requirement.

"When an Input Fields onEnter is been fired, row to the next should be selected"


//@@begin onEnterInputField(ServerEvent)

int lead = wdContext.nodeTable().getLeadSelection();
int size = wdContext.nodeTable().size();
if( lead < ( size - 1))
       wdContext.nodeTable().setLeadSelection( lead + 1);

//@@end

nikhil

Former Member
0 Kudos

Hi nikhil ,

i tried through ur way by creating a action named OnEnter and used the code as u hav provided but it

not working wen i am pressing enter on keyboared to initiate OnEnter action.So that the control shud go to next cell or the next row of the table.

Regards:

Hanif

nikhil_bose
Active Contributor
0 Kudos

I believe the Input field is a TableCellEditor and onEnter is been set to the same Input Field. Is this correct?

Former Member
0 Kudos

Yes the Input field is the cellEditor of the table but onEnter which initiate on enter press of K/B shud move the control from one cell of inputfield to next one of the table .

nikhil_bose
Active Contributor
0 Kudos

Hanif,

The mentioned approach and code will work fine. Please try placing the cursor inside the input field and press enter.

still not working? plz let me know what is the behaviour you see

nikhil

Former Member
0 Kudos

Hi nikhil i tries same again but the error is.......

The initial exception that caused the request to fail, was:

java.lang.NullPointerException

at com.sap.tc.webdynpro.progmodel.view.ContextBindingManager.getViewElementViaEditablePropertyBinding(ContextBindingManager.java:89)

at com.sap.tc.webdynpro.progmodel.view.View.requestFocus(View.java:420)

at com.sap.videocon.GridtableView.onActiononEnter(GridtableView.java:221)

at com.sap.videocon.wdp.InternalGridtableView.wdInvokeEventHandler(InternalGridtableView.java:153)

at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)

... 25 more

See full exception chain for details.

nikhil_bose
Active Contributor
0 Kudos

plz post code onActiononEnter()

Former Member
0 Kudos

hi nikhil its running to go to new row but how to achieve wen control/cursor to shift from one cell to adjacent cell of inputfield in table control

Former Member
0 Kudos

Hi nikhil one more thing i wud like 2 ask u..i..e..If thr r 2 rows insertted and now i want one more row to be inserted/added between these two rows how to achieve this using the action of getLeadSelection of the table so that exactly a row shud be added between these updated rows during runtime..

Waiting for reply...

Regards:

hanif

nikhil_bose
Active Contributor
0 Kudos

node.addElement( int index, IWDNodeElement newTableElement());
Former Member
0 Kudos

node.addElement( int index , IProjectElement newProjectElement());

giving error on the variable index ..how to resolve this?

Former Member
0 Kudos

hi nikhil reolve the using the code......

node.addElement( lead , element);

but the problem is wen i am selecting first row for leadselection upside rows are added and wen click to second row leadselect thn it is coming in between..

So how to resolve for the upcoming added rows for leadselect rather in between rows

Former Member
0 Kudos

Resolve the issue of lead selection between the two rows..

Well i want ask about tree in table control..hope u shall guide in this..

I want to add child node to the parent node at runtime..Basically i hav 5 attributes ProjectName,ProjectTask,ProjectUser,ProjectStartDate,ProjectEndDate..

Now i want to add these 4 attributes under ProjectName at runtime.

And after adding the attributes each attribute shud be in thier respective columns.

At runtime i want to make this provision of tree structure in the table control.

Hope u undertstand and anwser these one also..

Waiting for reply

Regards:

Hanif.

sanyev
Active Participant
0 Kudos

Hi Shaikh,

For the cursor to go to the next cell WDViewController.requestFocus(IWDNodeElement, IWDAttributeInfo)

is the only option that I am aware of.

When using the above api where are you getting null pointer exception?

The method that Nikhil mentioned will work only on leadselected row. You will have to get the row in which the cursor is currently. Do the following.

You want to get the node element (table row) in which the onEnter event of the input field (cell editor) "Editor" has been triggered:

Add a parameter "element" of type IWDNodeElement to the action "Action" assigned to the onEnter event.

Define a parameter mapping in wdDoModifyView():

if (firstTime)
{
  IWDInputField editor = (IWDInputField) view.getElement("Editor");
  editor.mappingOfOnAction().addSourceMapping
  (
    "nodeElement", /* name of (implicit) event parameter */
    "element" /* name of your action parameter */
  );
}

So at runtime your onEnter action handler will get the parameter element which is the current row the cursor is in now.

Assume you have 8 columns. You will have to create 8 different onEnter Actions because there in no other way to find out in which column the user clicked. In the implementation of the onEnter event of a particular column you should have the attributeInfo of the next column.

get the attributeInfo in this way

wdContext.getNodeInfo().getChild("Name").getChild("Name1").getAttribute("hardCodeAttributeName");

Don't forget to follow the context hierarchy to get to the node containing the attribute. If you use wdContext.nodeProject().getNodeInfo() if the node Project is empty you could possibly get a null pointer exception. The other way doesn't depend on data. See my [post|] explaining why.

Once you have the attribute info and the element in which the cursor is in now you can go ahead and call the request focus api.

wdThis.wdGetAPI().requestFocus(element,attr);

Make sure that from the last column you have to go to the first column of the next line. So get the next node Element

if(element.index() < element.node().size()){
   element = element.node().getElementAt(element.index()+1);
}

Let me know if you have any problems with this.

Sanyev

sanyev
Active Participant
0 Kudos

Hi Shaikh,

I have replied to the tree in a table problem in your other post.Take a look.

[;

Regards,

Sanyev

Former Member
0 Kudos

Please look the below thread

sanyev
Active Participant
0 Kudos

Hi Shaikh,

Your requirement is to go to a new line when the user does an enter on a table field right?

Your onEnter action handler of the table column should do the following.

First you have to create a new row in the table. On the context node which is bound to the table you need to create and add a new element.

IWDNodeElement element = wdContext.nodeTable().createElement();

wdContext.nodeTable().addElement(element);

There might be cases where the newly created row is not visible to the user. So you need to make the newly created row visible. For that you can set the property setFirstVisibleRow(int value) of the table dynamically.

You will not have access to the table UI element directly from your action handler. You will have to store your table in a publicly accessible place and then from your action handler modify the firstVisibleRow property of the table.

Even though all they are possible I would still recommend you to use a button in the toolbar for creating a new row instead of using onEnter event.

@Gayathri -- The link you have provided is for ABAP tables.

Regards,

Sanyev

Former Member
0 Kudos

Hi sanjeev thanx for reply. Well I have seen the pdfu2019s already but I am not the real stuff which I want. Basically I have binded the table to the context consisting 50 rows and each cell of the table is having Input field control so as to create a excel type of form in this webdynpro iView.

My requirement is to a workbench in which on each OnEnter action control shud go frm one cell to other or frm one row to other one.

I hav to make an application like MS Project Server 2007 if u hav seen.

Plz reply ASAP if u knows how to resolve this.

Waiting anxiously.

Regards:

hanif

sanyev
Active Participant
0 Kudos

Hi Hanif,

If I am correct your requirement is not to create a new row but just to set the focus to the next column right?

if that is the case you can check this method IWDViewController.requestFocus(IWDNodeElement, IWDAttributeInfo). See [API|http://help.sap.com/javadocs/NW04s/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDViewController.html#requestFocus(com.sap.tc.webdynpro.progmodel.api.IWDNodeElement, com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo)]

From the action handler on onEnter get the nodeElement and then use the above API to set the focus to the appropriate attribute.

Let me know if you need more info.

Regards,

Sanyev

Former Member
0 Kudos

Hi sanjeev used ur code but its showing null pointer xception......

IWDAttributeInfo attr = wdContext.nodeProject().getNodeInfo().getAttribute(wdContext.currentProjectElement().getPname());

wdThis.wdGetAPI().requestFocus(wdContext.currentProjectElement(),attr);

Former Member
0 Kudos

Hi,

Please go through this thread.

Regards,

Gayathri.