cancel
Showing results for 
Search instead for 
Did you mean: 

How can we enable or disable a Column of a table at runtime

Former Member
0 Kudos

How can we enable or disable a particular column of a table at run time

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Raghunandan,

Take one Boolean value in the context and bind it to the Particular column --> Table cell editor --> enable Property . Set it's value to True/False to Enable/Disable Column when your Required Condition Satisfies.

With Regards,

Roop Kumar.

Answers (3)

Answers (3)

Former Member
0 Kudos

hi...

You can make use of the Visibility property of the Table column to meet your requirement.

At runtime if you dont want to view particular column the Visible property of a column can be used.

In wdmodify View

IwdTableColumn column=(IwdTableColumn)view.getElement(<columnId>);

if(<Condition>)

column.setVisible(WDVisibility.NONE);

else

column.setVisible(WDVisibility.VISIBLE);

but as per your post you want to enable or disable the Table column...

this property can be applied only to the TableCellEditors which you can add in your TableColumn ...but not on the Table Column...Hope iam clear

Regards

Madhavi

former_member187439
Active Participant
0 Kudos

Hi ppl,

How about enabling and disabling table cell editor row wise?

For example, my table has 2 columns and number of rows depends on FM output. Column 1 has table cell editor as "input field" which should be enabled / disabled based on the values in column 2.

Say, For row 1, column 1 should be enabled. But for row 2, the same column 1should be disabled.

Very dynamic and the enable/disable decision is based on the value in column 2 coming from the FM. This is my requirement. Do you think its somehow possible? Pls let me know..

Thanks & Regards,

Kavitha

Former Member
0 Kudos

Yes, that's possible.

Example: Table with two columns, first column: InputField, second column LinkToAction. Link in each row should be enabled if value in input field is greater than 7.

Context:


Rows (node, cardinality=0;n)
-- value (integer)
-- linkEnabled (boolean, read-only, calculated=true)

Data binding:


InputField.value = Rows/@value
LinkToAction.enabled = Rows/@linkEnabled

Getter for calculated attribute:


boolean getRowsLinkEnabled(IRowsElement element)
{
  return element.getValue() > 7;
}

Armin

former_member187439
Active Participant
0 Kudos

I realised it after posting :). Just moved the enable/disable value attrbitue to the node which is mapped to the table. And modified the code such that, while creating and adding node elements, i check the condition and set this enable/disable value too. It works!

Former Member
0 Kudos

if you want to hide/show column thats what I understood use following properties:


	itemCol.setVisible(WDVisibility.BLANK); //to hide column			
  	itemCol.setVisible(WDVisibility.VISIBLE); //to show column

You can use LN's code to get your column, or iterate through the table object and modify your column properties.

	IWDTable table = (IWDTable)view.getElement("myTable");
	IWDAbstractTableColumn cols[] = table.getGroupedColumns(); //To get table column array
	IWDTableColumn itemCol = null;
			
	for (int i=0; i< cols.length; i++)
	{
		itemCol = (IWDTableColumn) cols<i>;
		if (<condition>)
			itemCol.setVisible(WDVisibility.BLANK);
		else
			itemCol.setVisible(WDVisibility.VISIBLE);
	}

Former Member
0 Kudos

HI,

In wdDoModifyView() method write the code to set enable or disable as

// if TableCellEditor of column is TextView then or replace //IWDTextView if any other..

IWDTextView col=(IWDTextView)view.getElement(<textViewId>);

if(<condition>)

col.setEnabled(<true or false>);

else

col.setEnabled(true or false);

Regards

LN

Edited by: Lakshmi Narayana Chowdary Namala on Sep 1, 2008 8:10 AM