cancel
Showing results for 
Search instead for 
Did you mean: 

create a new row with all fields as editable only in the new row

Former Member
0 Kudos

Hi

I have a table with 5 columns initially- 3 non editable and 2 editable, and 5 rows.

How do I create a new row(preferably on topmost line) with all fields as editable only in the new row?

The older row's non-editable rows must remain as they are.

jack

Accepted Solutions (1)

Accepted Solutions (1)

arun_srinivasan
Contributor
0 Kudos

hi jack,

In webdynpro it is not possible to create a row as editable.only column can be made as editable.

hope this helps u better,

Regards,

Arun

Former Member
0 Kudos

Hi Jack,

It is possible to meet your requirement in Web dynpro. Create as many context attributes (with data type as boolean) as the number of columns you have (say att1, att2, att3). Bind the readOnly property of the cell editors in table to these context attributes and set it to true / false, depending upon the requirement.

A new row can be added at the top of the table as the first row element by the code

wdContext.node<yourNode>.addElement(0,<yourElement>);

After adding a new row, set the attribute value for the cell editors to false.

wdContext.currentContextElement.setatt1(false);
wdContext.currentContextElement.setatt2(false);
wdContext.currentContextElement.setatt3(false);

In this way you can set the required row as well as the required cell editors to editable or non-editable.

Bala

Please reward appropriate points.

Former Member
0 Kudos

Hi Jack,

Here, you can also use single context attribute of type boolean to enable or disable the perticular row.

Other things suggested by Bala will work.

Regards,

Bhavik

Former Member
0 Kudos

Hi..thanks guys.

im facing a little issue...

<u>Recap of the scenario:</u>

1. Table with 5 ROWS, 5 COLUMNS.

2. 2 COLUMNS are editable, the rest are readonly.

3. there is a button to add new row.

4. when button is clicked, i add a new editable row with all fields in the ROW as editable in which the user can enter data and save it.

Problem is:

1. When i create a new row, and set the attributes as suggested by Bala, all <b>COLUMNS</b> marked as read-only:false are editable, whereas i only want the new blank editable <b>ROW</b> as read-only:false.

please help. if my explanation is unclear, please let me know.

jack.

Former Member
0 Kudos

Oops..

Please set the context attribute value to "TRUE" to make it non-editable. Set the attribute value for the first five rows to "TRUE" and set the attribute value to "FALSE" for the new rows that you are adding.This will solve the problem.

Bala

Please reward appropriate points.

Former Member
0 Kudos

Hi Bala

got that, but was wondering how i could set the rows to read only. i thought the attribute corresponded to the columns.

please let me know with code snippet how to set rows to readonly.

thanks for all help.

jack

Former Member
0 Kudos

Hi Jack,

One can play with the readOnly of table cell editor (Input Field) to acheive the expected result.

Let us take a specific case where your table has four columns say col1, col2, col3, col4 and each of these columns have Input field as the table cell editor.

Then depending upon the condition specified below choose your option.

<b><u>If you have bound the table to the model node</u></b>

1. Create a new value node and create a bolean value attribute under it.

2. Set the cardinality of the value node to 1:1 and singleton to false.

3. Bind this attribute to the Table cell editor (Inputfield) in col1, col2, col3 and col4.

4. set the value of this attribute to <b>TRUE</b> when the table gets filled up initially i.e for the first five elements/rows, as per your requirement.

5. In the onActionAdd() method set the boolean attribute to <b>FALSE</b>, so that all the four Input fileds in the four columns of the specific element that you add will become readonly.

<b><u>If you have bound the table to a value node</u></b>

1. Create a value attribute of type boolean under the value node and follow the ONLY the steps <b>3</b>, <b>4</b> and <b>5</b>

Former Member
0 Kudos

Hi Bala,

Lets say you have node Node1 which is bound to table.

Create one value attribute of type boolean in it.

When you populate this node with values, at that time set its value as TRUE. But for newly created node element set its value as FALSE.

Now, in layout assign this value attribute to all the columns in which you want the editability.

Regards,

Bhavik

Former Member
0 Kudos

Sorry Jack.

Bhavik is right. Again I mixed up the values TRUE / FALSE. Just refer my post again. I've highlighted the correct values now.

Bala

Message was edited by: Bala Krishnan

Former Member
0 Kudos

Hi

I have followed all the steps, but I am not able to set only the new created row to ediatable. either everything is read only or everything is editable.

this is my code:

in the init(for testing, i populate the table from here), i write:

wdContext.currentContextElement().setReadOnly(<b>true</b>);

onActionAdd()

{

wdContext.currentContextElement().setReadOnly(<b>false</b>);

IPrivateUpdateTableView.IDetailedUpdateTableNodeElement el = wdContext.createDetailedUpdateTableNodeElement();

el.setCUSTOMER_NUMBER("");

el.setORDER_NUMBER("");

el.setDOCUMENT_DATE("");

el.setMATERIAL("");--><i>always editable column</i>

el.setQUANTITY("");--><i>always editable column</i>

wdContext.nodeDetailedUpdateTableNode().addElement(0,el);

}

In the layout, I have bound the ReadOnly attribute in all the input fields of the table.

what am I doing wrong??

jack

Former Member
0 Kudos

You cannot control the read-only state of individual rows using one global context attribute.

In your example: Add a boolean attribute "readOnly" to node "DetailedUpdateTableNode".

If this node has a structure binding (which I guess in your case), you cannot add attributes directly. Add a node "State" (cardinality=1:1, selection=1:1, singleton=false) under "DetailedUpdateTableNode" and add the "readOnly" attribute there.

Bind the "readOnly" property of your table cell editors (InputField) to this attribute.

In the action handler "onActionAdd":

onActionAdd()
{
  /* remove this line from original code */
  /* wdContext.currentContextElement().setReadOnly(false); */

  IPrivateUpdateTableView.IDetailedUpdateTableNodeElement el = wdContext.createDetailedUpdateTableNodeElement();
  el.setCUSTOMER_NUMBER("");
  el.setORDER_NUMBER("");
  el.setDOCUMENT_DATE("");
  el.setMATERIAL("");-->always editable column
  el.setQUANTITY("");-->always editable column
  /* set new "row" to editable */
  el.nodeState().setReadOnly(false);
  wdContext.nodeDetailedUpdateTableNode().addElement(0,el);
}

Armin

Former Member
0 Kudos

Hi Jack,

You have created attribute in main context. But you have to create it under the node "DetailedUpdateTableNode".

Now, When you are setting values for each element in this node set its value as true and only for newly created node set its value as false.

Regards,

Bhavik

Answers (0)