cancel
Showing results for 
Search instead for 
Did you mean: 

Insert Empty row in table

former_member1193316
Participant
0 Kudos

Hi,

i m having a table and displaying data by fetching from backend.

i added a toolbar item called button and named it as "Insert".

when i click on thins button the first row of the table should be empty with input fields. i want to insert data and when i click on save button it should update at backend.

kindly let me know how to insert empty row at starting of table.

thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Venkat,

In order to edit a column in the table, the table cell editor of that column should be an input field. When you bind a table to a node, by default the table cell editor will be TextView. If you have already bound the table to node, first right click the desired column of the table and remove Table Cell Editor and then again right click and select 'Insert Table Cell Editor'. In the next screen select 'InputFiled'.

Thanks and Regards,

Shabeer.

former_member1193316
Participant
0 Kudos

all the feilds are input fields.

i want only selected row should be editable. all others should be non-editable.

how to do this

Former Member
0 Kudos

Hi,

Create an attribute of type boolean under the node bound to the table, and bind this to the readOnly property of the inputbox.

create an action for onLeadSelect, based on the selected element (Will be available as part of the parameter to this action) change the values of the attribute bind to the readonly property from true to false.

Regards

Ayyapparaj

Former Member
0 Kudos

hai venkat,

bind an attribute of type boolean to the readonly property of the inputfield.

->create a method method1()

->inside the method check the boolean value and enable or disable the fields.

->call this method on onleadselect prperty of the inputfield.

regards

Sharanya.R

former_member1193316
Participant
0 Kudos

I followed the same.

but when i click on new inserted row, along with new row all other rows also coming to editalbe.

how to edit only selected row. not other rows.

i binded " edit" value attribute of type boolean to the table inputfields.

former_member1193316
Participant
0 Kudos

her i m having node itab. which is coming from model.

so i couldnt able to create a new value attribute of type boolean under itab.

so without adding under itab, its no use.

now tell me the solution plz.....

Former Member
0 Kudos

hai venkat,

get the node size before you create a new row.so start the for loop from the node size so that it ll consider only the current row.

Regards

Sharanya.R

Answers (3)

Answers (3)

Former Member
0 Kudos

[IWDNode.addElement()|https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDNode.html#addElement(int,%20com.sap.tc.webdynpro.progmodel.api.IWDNodeElement)]

Armin

Former Member
0 Kudos

hai venkat,

To add an empty row when addrow button is clicked here is the coding,

public void onActionaddrow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionaddrow(ServerEvent)

try

{

IPrivateSalesdet.ITablepartnersNode noder=wdContext.nodeTablepartners();

IPrivateSalesdet.ITablepartnersElement elem;

for(int i=0;i<1;i++)

{

elem= noder.createTablepartnersElement();

noder.addElement(elem);

IPrivateSalesdet.ITablepartnerssubnodeNode nodeEd=wdContext.nodeTablepartnerssubnode();

IPrivateSalesdet.ITablepartnerssubnodeElement EdEle;

for(int i=0;i<1;i++)

{

EdEle = nodeEd.createTablepartnerssubnodeElement();

nodeEd.addElement(EdEle);

}

}

catch(Exception e)

{

}

Regards

Sharanya.R

Edited by: Sharanya R on Feb 4, 2008 12:54 PM

former_member1193316
Participant
0 Kudos

Hi Sharanya...

Thanks for ur inputs.

i can able to insert an empty row. but its inserting at last row of the table. i want to insert at BEGINING.

here the inserted row should be editeable. i mean it hav to insert some values and press save button. it shoud update in databasse table.

first inserted row should be editable and all others should b non-editable.

how can i achieve this.

thanks in advance...

venkat

Former Member
0 Kudos

hai venkat,

In order to insert the row in the beginning try giving

wdContext.nodeTable().moveFirst(); before you start creating a new row.

regards

Sharanya.R

former_member1193316
Participant
0 Kudos

Hi Sharanya,

here is my code....

where i need to insert ur statement?

plz guide me... and this inserted row should be editable....

how could i do this?

public void onActionNew_Employee(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionNew_Employee(ServerEvent)

try

{

IPrivateDisplayView.IItabNode node = wdContext.nodeItab();

IPrivateDisplayView.IItabElement elem;

for(int i =0;i<1;i++)

{

elem = node.createItabElement(new Zemp_Master());

node.addElement(elem);

IPrivateDisplayView.IInsertNode node1 = wdContext.nodeInsert();

IPrivateDisplayView.IInsertElement elem1;

for( i=0;i<1;i++)

{

elem1 = node1.createInsertElement();

node1.addElement(elem1);

}

}

}

catch(Exception ex)

{

}

Thanks in advance

Former Member
0 Kudos

Hi,

You can use:

for(int i =0;i<1;i++)

{

elem = node.createItabElement(new Zemp_Master());

node.addElement(0,elem); // specify index

IPrivateDisplayView.IInsertNode node1 = wdContext.nodeInsert();

IPrivateDisplayView.IInsertElement elem1;

for( i=0;i<1;i++)

{

elem1 = node1.createInsertElement();

node1.addElement(0,elem1);

}

}

hope this will solve your problem.

thanks & regards,

Manoj

Edited by: Manoj Kumar on Feb 5, 2008 9:53 AM

Former Member
0 Kudos

hai venkat,

try to use manoj,s coding.hope that ll work for your case.If not add wdContext.nodetable().movefirst(); in the first line of the for loop you are using to create elements(row).

for( i=0;i<1;i++)

{

wdContext.nodetable().movefirst();

elem1 = node1.createInsertElement();

node1.addElement(elem1);

}

regards

Sharanya.R

Edited by: Sharanya R on Feb 5, 2008 5:46 AM

former_member1193316
Participant
0 Kudos

Sharanya and manoj,

thanks for ur inputs. its working fine.

but could you please let me know, when i select that row, it should be editable. like input feilds, i should enter soem values...

Former Member
0 Kudos

Hi,

Their are two ways to make an empty row

One is set the cardinaliity of the node bound to the table as 1..n

or else create an element in the init as

wdContext.node<YOURNODE>().createAndAddElement();

Regards

Ayyapparaj