cancel
Showing results for 
Search instead for 
Did you mean: 

Changing value of table cell

Former Member
0 Kudos
41

Hello all,

I am trying to do the following:

I have a table on a page, which has 3 columns. When a user selects a row, and clicks on the button find, a popup window will appear, and the user can click through some fields. At the end, the user selects a value, and clicks on a button.

When that button is pressed, the selected value has to be inserted into the 2nd column of the row the user selected.

How can I do that? One big problem is, that I don't have the context available. The columns for the table are not defined in the context statically, I guess dynamically. (I am modifying an existing web dynpro)

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Do you atleast know the name of the attribute that is bound to the second column? If yes then you can simply get the element at lead selection for the datasource node of the table and set that attribute with the selected value from the user

Regards,

Satyajit.

Former Member
0 Kudos

I think so, but could you give me a coding example?

Former Member
0 Kudos

The coordinates of a table cell in the selected row are given by

- lead selection of data source node

- Attribute(s) to which the cell editor properties for that column are bound

Example:

Data source node "Rows"

Attribute "text"

Column 2 editor: InputField with "value" bound to "Rows.text"

Then you can access the value using

wdContext.nodeRows().currentRowsElement().getText();

or the corresponding generic context API, if the context is created programmatically or typed access was switched off.

Armin

Former Member
0 Kudos

I know how to do it when I have the context available, unfortunately, that's not the case. It's done dynamically, and I can't seem to be able to get access to the dynamic context. At least, I am not succeeding as of yet...

So suppose you have value node in the context.

That value node is all you have, but to that value node, dynamically, new thigns have been added, which leads to a table in the UI.

How can I change values of elements in that table?

Former Member
0 Kudos

Don't have the source code available? Additionally, you could use the debugger to see which table cell editor is used and how its properties are bound. Then you have all needed information.

Armin

Former Member
0 Kudos

The source code is a little too complex for me right now, since it's a standard SAP scenario (CATS). The table is filled through an rfc connection.

Anyhow, i have found some more info, that maybe lets you help me more:

When i go to the NodeInfo, and from there do:

IWDAttributeInfo attInfo = timesheetInfo.getAttribute("RAUFNR_Value");

It exists, so I guess I have found the attribute i need to change (RAUFNR_Value).

If i have that, and the node is in timesheetData, and the nodeInfo is in timesheetInfo, how do I change the attribute RAUFNR_Value ?

Former Member
0 Kudos

If node "timesheetData" allows typed access:


ITimesheetDataElement e = wdContext.nodeTimesheetData().currentTimesheetDataElement();
e.setAttributeValue("RAUFNR_Value", value);

Armin

Former Member
0 Kudos

Unfortunately, that's not possible.

However, I seem to have come closer to a solution:

Like I said in my first post, a user selects a row, then clicks on a button, then selects a value, and then clicks on a button again to put the value from the popup window into the corresponding cell in the table.

Now, when I add the following code to the function that shows the popup window, the corresponding cell gets filled:

IWDNode timesheetData = wdThis.wdGetFcCatRecordInterface().wdGetAPI().getContext().getRootNode().getChildNode("TimesheetData", IWDNode.LEAD_SELECTION);

timesheetData.getCurrentElement().setAttributeValue("RAUFNR_Value", "12345");

However, when I add the exact same code to the method that gets fired when a user selects a value and clicks on the button in the popupwindow , i get a java.lang.NullPointerException on the setAttributeValue bit.

If you can solve that last bit, I think I'm good to go!

Former Member
0 Kudos

Ok,

I solved it, I couldn't use currentContextElement, so I put an integer into the context and stored the row in there. Then use that integer with getElementAt().

Thanks for all your help!

Answers (0)