cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling/Disabling Table Cells

Former Member
0 Kudos

H

I have a table with every row having a checkbox.

Based on this value of checkbox i enable/disable fields...

Can you let me know how to capture this table cell...

I wrote


int iTabSize = wdContext.nodeNodeTblAppr().size();
boolean flagApprove = true;
boolean flagReject = true;
		
IWDInputField[] validityDate = null;
IWDInputField[] comments = null;
IWDCheckBox[] chk_approve = null;
IWDCheckBox[] chk_reject = null;
		
for(int i=0;i<iTabSize;i++)
{
validityDate<i> = (IWDInputField) view.getElement("ctx_Validity_0_editor");
comments<i> 	= (IWDInputField) view.getElement("ctx_Comments_0_editor");
chk_approve<i>  = (IWDCheckBox) view.getElement("ctx_Approve_0_editor");
chk_reject<i>   = (IWDCheckBox) view.getElement("ctx_Reject_0_editor");
		
flagApprove = chk_approve<i>.getChecked();
flagReject = chk_reject<i>.getChecked();
	
if(flagApprove || flagReject)
{
validityDate<i>.setEnabled(true);
comments<i>.setEnabled(true);
}
}

Its throwing me a null pointer exception at view.getElement("ctx_Validity_0_editor");

where "ctx_Validity_0_editor" is the TableCellEditors's name...

I know i must be making a very stupid mistake...

plz let me know...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Devashish,

This can be done easily through calculated attributes rather than doing it programatically in wdDoModifyView().

In the node "NodeTBlAppr", create a value attribute (VA1) of type <i>boolean</i> and bind it to the <i>checked</i> property of check box.

Then, create a calculated attribute (VA2) of type boolean under the same node and bind it to the enabled property of the inputfields "validityDate" and "comments".

Create an actionHandler for check box and bind it to the event "onToggle" of the check box.

In the generated getter of the calculated attribute write

return element.getVA1();

In the generated setter write

element.setVA2(value);

Bala

Answers (1)

Answers (1)

Former Member
0 Kudos

I don't understand this code.

First, as you try to access view element references, I suppose this is inside wdDoModifyView().

Don't access view element references for setting property values. Use data binding to context attributes/nodes instead.

Second, what are these <b>arrays</b> of UI elements good for?

Remove this coding and do it like this:

Create boolean context attributes "Approved" and "Rejected" inside the context node used as table data source.

<b>Bind </b> the "checked" property of the check boxes (table cell editors) to these properties.

Create a calculated attribute "InputFieldReadOnly", type=boolean, readOnly=true, inside the context node mentioned above.

<b>Bind</b> the "readOnly" property of your input fields (table cell editors) to this calculated attribute.

In the generated get...InputFieldReadOnly(IWDNodeElement element) method, cast the parameter "element" to the concrete, generated node element type (IPrivate<View>.I<Node>Element) and return true, if the input fields in this row (node element corresponds to table row) should be read-only.

Lastly, assign an empty action to the "onToggle" event of the checkboxes to get a server-roundtrip when a checkbox is clicked.

Armin

Former Member
0 Kudos

Thank you Bala & Armin...

Problem is solved...