cancel
Showing results for 
Search instead for 
Did you mean: 

how to add a row to table

Former Member
0 Kudos

HI,

i have 1 row(visible row count=1) and 2 columns in atable with dropdownbyindex and inputfield and i have two buttons ADD and DELETE when ever i click ADD button a new row should be appended to the existing row .and when i click on DELETE selected row should be deleted,can u please send the required code for this scenario.

thanks

kishore

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Kishore,

Context Node --> Table

Code for Addition,

ArrayList arlTempPrevData = null;

ArrayList arlTempNextData = null;

ITableElement objTable = null;

int intSize = 0;

try

{

arlTempPrevData = new ArrayList();

arlTempNextData = new ArrayList();

objTable = wdContext.createTableElement();

intSize = wdContext.nodeTable().size();

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

{

arlTempPrevData.add(wdContext.nodeTable().getTableElementAt(i));

}

objTable.setCtx_EmpID(wdContext.nodeTable().currentTableElement().getCtx_EmpID());

objTable.setCtx_Desig(wdContext.nodeTable().currentTableElement().getCtx_Desig());

arlTempPrevData.add(intSize,objTable);

wdContext.nodeTable().bind(arlTempPrevData);

}

catch(Exception e)

{

msgMgr.reportException(e.getLocalizedMessage(),true);

}

Code for Deletion,

IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();

ArrayList arlTempPrevData = null;

ArrayList arlTempNextData = null;

int intSize = 0;

try

{

arlTempPrevData = new ArrayList();

arlTempNextData = new ArrayList();

intSize = wdContext.nodeTable().size();

wdContext.nodeTable().removeElement(wdContext.currentTableElement());

}

catch(Exception e)

{

msgMgr.reportException(e.getLocalizedMessage(),true);

}

Regards

Roshni

Former Member
0 Kudos

Hi,

Whenever u want to add a row to table you can create a new element of corresponding binded node and whenever u want to delete the row just you can remove element that corresponding element from that node.

To Add element

IPrivateVIEWNAME.INodenameElement

instance;

Instance = wdContext.nodeNodename().createNodenameElement();

//after creating u can access attribute of node using

Instance.setatttributename();

//Now add element to node

wdContext.nodeNodename.addElement(Instance);

To delete element...

get the curent lead selection.

IWDNode node;

node = wdContext.wdGetAPI().getRootNode().getChildNode("Node Name",IWDNode.LEAD_SELECTION);

IWDNodeElement nodeele ;

nodeele = node.getElementAt(curent lead select+1);

node.removeElement(nodeele);

Regards

Surender Dahiya

Edited by: Surender Dahiya on May 15, 2008 8:30 AM

Former Member
0 Kudos

hi,

for appending record use add record and for deleting the record use delete record action.

public void addRecord( )

{

//@@begin addRecord()

WfTmTeam team = wdContext.nodeWF_TM_TEAM().currentWF_TM_TEAMElement().modelObject();

WfTmLearnpath modelLearnPath = team.createWfTmLearnpath();

IPublicHrtlm.IWfTmLearnpathElement eleLearnPath = wdContext.createWfTmLearnpathElement(modelLearnPath);

wdContext.nodeWfTmLearnpath().addElement(eleLearnPath);

wdContext.nodeWfTmLearnpath().moveLast();

//@@end

}

public void DeleteRecord( )

{

//@@begin DeleteLearnPathRecord()

int size=wdContext.nodeWfTmLearnpath().size();

int leadSelect=wdContext.nodeWfTmLearnpath().getLeadSelection();

for (int i = size - 1; i >= 0; --i) {

if (leadSelect == i) {

wdContext.nodeWfTmLearnpath().removeElement(wdContext.nodeWfTmLearnpath().getElementAt(i));

}

}

Regards

Trilochan

Former Member
0 Kudos

hi trilochan thanks for u reply if u dont mind can u please expalin me clearly that code whichu have send me.

thanks

kishore

Former Member
0 Kudos

hi,

first create a model object if u have model node and then create an element using this model object.

add this element to the node which are binded with ur table.

and for value node u can use only for add record

IPrivateSetDataView.IABCElement ele= wdContext.nodeABC().createABCElement();

wdContext.nodeABC().addElement(ele);

public void addRecord( )

{

//@@begin addRecord()

WfTmTeam team = wdContext.nodeWF_TM_TEAM().currentWF_TM_TEAMElement().modelObject();

WfTmLearnpath modelLearnPath = team.createWfTmLearnpath();

IPublicHrtlm.IWfTmLearnpathElement eleLearnPath =wdContext.createWfTmLearnpathElement(modelLearnPath);

wdContext.nodeWfTmLearnpath().addElement(eleLearnPath);

wdContext.nodeWfTmLearnpath().moveLast();

//@@end

}

and in delete record first get the size of node and get leadSelection of that node after that remove the selected element(according to ur lead selection).

public void DeleteRecord( )

{

//@@begin DeleteLearnPathRecord()

int size=wdContext.nodeWfTmLearnpath().size();

int leadSelect=wdContext.nodeWfTmLearnpath().getLeadSelection();

for (int i = size - 1; i >= 0; --i) {

if (leadSelect == i) {

wdContext.nodeWfTmLearnpath().removeElement(wdContext.nodeWfTmLearnpath().getElementAt(i));

}

}

Regards

Trilochan

Edited by: Trilochan Bagauli on May 15, 2008 9:19 AM

Former Member
0 Kudos

Hi,

To ADD:

1. Create element of the node with which your dropdown is mapped.

wdContext.node<NODE NAME>().create<NODE NAME>Element();

2. Add this element to the node using add() methiod.

3. Set the required attributes for this element.

To Delete:

wdContext.node<NODE NAME>().removeElement(your current element);

Hope this helps.

thanks & regards,

Manoj