cancel
Showing results for 
Search instead for 
Did you mean: 

Hide table column during runtime

Former Member
0 Kudos

how to hide a table column for eg tablename: custTable column id: col_custid

pls advice

Message was edited by:

yzme yzme

Accepted Solutions (1)

Accepted Solutions (1)

former_member751941
Active Contributor
0 Kudos

hi yzme,

Check the cardinality of Node "Visibility".If it is 0..1 or 0..n you have to initialized it.

For 0..n node use code inside wdDoInit.

wdContext.node<node_name>().addElement(wdContext.create<node_name>Element());

For 0..1 node use code inside wdDoInit.

wdContext.node<node_name>().bind(wdContext.create<node_name>Element());

Or you can make node (“Visibility”) cardinality either 1..1 or 1..n

Without creating any element you can’t set the value to the context node attribute like.

wdContext.currentVisibilityElement().setD29Visible(WDVisibility.VISIBLE);

wdContext.currentVisibilityElement().setD30Visible(WDVisibility.NONE);

wdContext.currentVisibilityElement().setD31Visible(WDVisibility.NONE);

If you initialize the node (Visibility) you will not get null pointer exception.

But if you create a table using the node “Visibility” it will not hide your table column. It will add a record in the table like.

-


VISIBLE NONE NONE

-


To hide the table column [by id] use the code inside wdDoModifyView

-


IWDTableColumn custidtableCol = (IWDTableColumn)view.getElement("col_custid");

custidtableCol.setVisible(WDVisibility.NONE);

Regards,

Mithu

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

You can use Visibility Options for this.

Create a Value attribute of type Visibility which will be available in the Dictionary.

Bind IWDTableColumn.visible property to context attribute of (DDIC) type Visibility. Set attribute value to WDVisibility.NONE to hide column.

Once it is binded , you can change the Visibility behaviour by coding wherever u want :

wdcontext.currentContextElent().setVisibility("NONE");

Regards,

Santhosh

Former Member
0 Kudos

i hit null pointer exception

what wrong with my code

Visibility

-d29Visible

-d30Visible

-d31Visible

wdContext.currentVisibilityElement().setD29Visible(WDVisibility.VISIBLE);

wdContext.currentVisibilityElement().setD30Visible(WDVisibility.NONE);

wdContext.currentVisibilityElement().setD31Visible(WDVisibility.NONE);

Message was edited by:

yzme yzme

Former Member
0 Kudos

Hi,

IWDTableColumn CustIDCol = (IWDTableColumn)view.getElement("col_custid");

CustIDCol.setVisible(WDVisibility.NONE); // To hide column

CustIDCol.setVisible(WDVisibility.VISIBLE);//To view column

Node : Visibility

Attributes : d29Visible, d30Visible, d31Visible

wdContext.currentVisibilityElement().setd29Visible(WDVisibility.VISIBLE);

wdContext.currentVisibilityElement().setd30Visible(WDVisibility.NONE);

wdContext.currentVisibilityElement().setd31Visible(WDVisibility.NONE);

Attributes : d29Visible, d30Visible, d31Visible should be <b>com.sap.ide.webdynpro .uielementdefinition .Visibility</b> of type.

Regards

Vasundhara

Former Member
0 Kudos

Hi Yzme,

can u just post the structure of your node... also tell me whether "Visibility" is the Child node or Parent Node.

Regards / Guru

Sunitkroy
Participant
0 Kudos

Hi

Most probably cardinality of your node in which d29 resides is 0 to n. So you have to create element for that node.

regards

Sunit

Former Member
0 Kudos

Hi Yzme,

Bind IWDTableColumn.visible property to context attribute of (DDIC) type Visibility.

Set attribute value to WDVisibility.NONE to hide column.

Regards,

Jhansi

Sunitkroy
Participant
0 Kudos

Hi

You first create an attribute say saveView of type com.sap.ide.webdynpro.uielementdefinitions.Visibility

Now go to the property of the element col_custid you want to hide and bind the visible property to the above attribute saveView .

Now depending upon your condition you may hide your element

by the code in view

wdContext.currentContextElement().setSaveView(WDVisibility.NONE)

regards

Sunit

Former Member
0 Kudos

chk it