cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Table Input Field - Disabled in runtime

michael_pang4
Active Participant
0 Kudos

Hi,

I have dynamically created a node. The node as a string attribute X.

Then dynamically created a IWDTable to bind to the node.

In the table I have a column, then a tablecelleditor of inputfield.

The inputfield 'value' is binded to node->X attribute info.

inputField.bindValue(attributeInfo).

Then I created a few entries of the node, populating X with some dummy value.

In runtime, my inputfields are disabled, and the dummy values don't appear.

I believe it is something to do with my binding.

Then I replaced the inputfield with a textview. textview text is binded to the node->X

attribute info.

textview.bindText(attributeInfo)

(i.e. exact same attribute info I used for the inputfield)

In runtime I see my textview with the dummy values.

Can anyone point me in the right direction?

Cheers,

Michael.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Michael,

Given the fact that TextView works but InputField doesn't I can only guess there is an issue with read-only property of newly created attribute. However this doesn't explain missing value... Are you sure you are using same "attributeinfo" in both versions of code?

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi Michael,

Looks like a Cardinality Issue, Check if the Inputfield has 1..1 or 1..n.

if u bind a node ,u have to create an element for it and then u have to set value for it.

If the cardinality is 1:n, the element will be created automatically.

i.e without an element u cannot set values.

and in case of input field if ur not binding it wont be enabled and the values won't appear.

Points, if the info was helpful would be appreciated.

Regards,

Anish

michael_pang4
Active Participant
0 Kudos

Hi Anish,

Thanks for your reply.

As the node is "dynamically" created, I called the createChild method in wdContext.getAttributeInfo() it by setting 'multiple = true' and singleton = 'true'.

Also, since I have already created lines in the table using the createElement method, I'm sure the content is at least 1..n.

I created a variable called to represent the attribute info, hence the attribute info must be the same for both the textview and the inputfield.

Any ideas?

Cheers,

Michael.

Former Member
0 Kudos

Hi Michael,

Can u check the size of the node after adding elemnets by

IWDNode node=(IWDNode)wdContext.getChildNode("NodeID_In_NodeInfo",0);

wdComponentAPI.getMessageManager().reportSuccess("Size after adding Elements is "+node.size());

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi Michael,

Thanks for the points...

Guess you are right on where the issue was then. If you have gone thru the sap help document you will find this info on binding

The data of a table is bound at two locations:

· The dataSourceproperty of the table must be bound to a context node.

· A TableCellEditor is assigned to each column. The text property or valueproperty of the TableCellEditor is bound to a context attribute.

At runtime, the number of rows is determined by the number of node elements

Please check if you have done this binding at runtime to get the dummy data. I think if you study the Table @ help.sap.com

http://help.sap.com/saphelp_nw2004s/helpdata/en/b8/f87842fdb70f53e10000000a155106/frameset.htm, you might find a solution on this.

let me know if this helps...

Regards,

Anish

michael_pang4
Active Participant
0 Kudos

Hi Guys,

I think to be clear I better include my code here.

I did bind the table to the nodeInfo, and I did bind the textView/inputfield to the particular attribute.

As mentioned before, it does show for the textView, but not for the inputfield.


Create the new node:
		IWDNodeInfo newNode = wdContext.getNodeInfo().getChild("nodeName");

			newNode =
				wdContext.getNodeInfo().addChild(
					"nodeName",
					null,
					true,
					true,
					true,
					false,
					false,
					true,
					null,
					null,
					null);

Create the attribute:
			IWDAttributeInfo detailAttribute =
				newNode.addAttribute(
					"xyz",
					"ddic:com.sap.dictionary.string");


Get the node
					IWDNode specificNode =
						wdContext.getChildNode(
							"nodeName",
							0);

Create the element from the node
					newElement =
							specificNode.createElement();
Set the attribute value:
						newElement.setAttributeValue(
							"xyz",
							"1234");
Add the new element:
						specificNode.addElement(newElement);

Create the table now:
			
			IWDTable someTable =
				(IWDTable) view.createElement(
					IWDTable.class,
					"TAB_ArticleQty" + articleElement.getArticleId());
			someTable.setEnabled(true);
			someTable.setReadOnly(false);
			someTable.setRowSelectable(true);
			someTable.setFooterVisible(false);
			someTable.setSelectionMode(WDTableSelectionMode.NONE);
			someTable.setVisibleRowCount(-1);
			someTable.bindDataSource( 
			specificNode.getNodeInfo());
			TC.addChild(someTable);


Loop at all the attributes and create the column
The code for the textView has been commented out
The code is now for the input field
			/*
			 * LOOP AT ALL THE ATTRIBUTES IN THE NODE:
			 * CREATE ONE COLUMN FOR EACH ATTRIBUTE
			 */

			Iterator allAttributes =
			specificNode.getNodeInfo().iterateAttributes();
			while (allAttributes.hasNext()) {
				IWDAttributeInfo attrInfo =
					(IWDAttributeInfo) allAttributes.next();
				String attrName = attrInfo.getName();
.....
					/*
						// Text View 
						IWDTextView TV_info =
							(IWDTextView) view.createElement(
								IWDTextView.class,
								"TV_AQ_"
									+ counter
									+ attrName);
						TV_info.bindText(attrInfo);
						COL_qty.setTableCellEditor(TV_info);
					*/
						//input field for the user to enter the value
						IWDInputField input_Qty =
							(IWDInputField) view.createElement(
								IWDInputField.class,
								"input_Qty"
									+ counter
									+ attrName);
						input_Qty.setEnabled(true);
						input_Qty.bindValue(attrInfo);
						input_Qty.setWidth("4");
						COL_qty.setTableCellEditor(input_Qty);
					someTab.addColumn(COL_qty);

			}

Former Member
0 Kudos

Michael,

Your code looks ok in general, however:

1. I see no code for creating column. Did you post complete code.

2. The sequence of calls is a bit unclear -- where do you creating node? In action handler or in wdDoModifyView?

3. The following looks like wired combo to me:


someTable.setEnabled(true);
someTable.setReadOnly(false);
someTable.setRowSelectable(true);
someTable.setFooterVisible(false);
someTable.setSelectionMode(WDTableSelectionMode.NONE);
someTable.setVisibleRowCount(-1);

Could you try to test with just the following (all rows / no footer):


someTable.setFooterVisible(false);
someTable.setVisibleRowCount(-1);

4. Call <i>IWDNodeInfo newNode = wdContext.getNodeInfo().getChild("nodeName");</i> is redundant -- just remove it.

5. If you do not need UI elements ID -- then just put null as second parameter to createElement

Valery Silaev

SaM Solutions

http://www.sam-solutions.net