cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically adding a row and context binding

Former Member
0 Kudos

Hi All

i need to display existing values in DB in row wise

Also there is a add button on click of this add button i need to insert a row along with the exiting rows

and also bind a context to the new row.

Finally on clicking of Save button i need to update this to a database table

Please guide me how to insert a row dynamically and binding context to it

client dont want to use table.

Thanks

Karthi D.

Edited by: karthi D on Aug 22, 2008 6:35 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Displaying table data in view without using table takes time and you need to work more.

To display the table data follow the below steps

1. Create the "TransparentContainer" UI element in view

2. create the context node and attribute according to your table data

3. get the table data and bind to context

IPrivateSDNView.ITableDataNode node = wdContext.nodeTableData();

IPrivateSDNView.ITableDataElement ele = null;

for(int i=0;i<tableRecords.length;i++) {

ele = node.createTableDataElement();

ele.setId(); // set your data to all attributes

node.addElement(ele);

}

4.in wdDoModifyView get the "TransparentContainer" UI element and set the layout and col size (ex: 4)

IWDTransparentContainer tContainer = (IWDTransparentContainer)view.getElement("TransparentContainer");

IWDGridLayout gridLayout = (IWDGridLayout)tContainer.createLayout(IWDGridLayout.class);

gridLayout.setColCount(4);

tContainer.destroyAllChildren();

5. Create the UI elements (textview, label ....) and add to tContainer

IPrivateSDNView.ITableDataNode node = wdContext.nodeTableData();

IWDTextView textView = null;

int count = 0;

for(int i=0;i<node.size();i++) {

count = 0;

textView = (IWDTextView)view.createElement(IWDTextView.class,""i(count++));

textView.setText(node.getTableDataElementAt(i).getAtt1());

tContainer.addChild(textView);

textView = (IWDTextView)view.createElement(IWDTextView.class,""i(count++));

textView.setText(node.getEmpDataElementAt(i).getAtt2());

tContainer.addChild(textView);

}

To insert records into the above table

1. Create the form with your fields with add button with Action "Add"

2. Create the context for this form

3. In onActionAdd method add the element to TableData node context

Let me know if you are not cleared with above code

Thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Karthi,

Can the TABLE where you want to insert the data in database change at runtime?

If no, i.e. you are going to add data for only 1 table then,

1. Create a Context Node represting the table (Suppose, TestTable)

2. Add your context attributes to this Context Node.

3. Using Apply template, create a tbale for the Context Node create in step 1.

Remember, to use InputField as youe Cell Editor for all the columns.

4. Create a button for Adding Row, the onAction will be as,

IPrivate<View_Name>.ITestTableElement eleOfTable = wdcontext().nodeTestTable().createTestTableElement();

This will add an empty row to your table, which can referenced using eleOfTable.

Regards,

Alka.

siddharth_jain
Active Contributor
0 Kudos