cancel
Showing results for 
Search instead for 
Did you mean: 

Seeting Visibility to Table

Former Member
0 Kudos

Hi

I followed link and I was able to set visbility to cell editor of table. There are no errors but I found that

if any condition is false(in all rows of table) whole visibility is gone it any condition is true whole table is displayed.

ie If condition is false I can see celleditors else every thing is blank.it is supposed to check condition for each cell editor. Please see below code and suggest me if i am wrong

for (int i = 0; i < wdContext.<NODE>.size(); i++) {

IPrivate<VIEWNAME>.I<NODEElement> row1=wdContext.node<NODE>().get<NODEElementAt>(i);

v.setVisible(<CONDITION> ? WDVisibility.NONE :WDVisibility.VISIBLE);

}

My node structure is Node-->Visible(node)

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I have changed the code but still that problem persists.

Former Member
0 Kudos

Ok, explain what


row.getId() == 0

is supposed to do.

Armin

Former Member
0 Kudos

col1                         col2
-----------------------------------------
col1row1             col2row1
col1row2              col2row2 

getId is value of col1row1 and col1row2.

if(row.getId ==0) ie col1row2 is true then hide col2row2.

Former Member
0 Kudos

What is the data type of attribute "id"?

Armin

Former Member
0 Kudos

Short is data type of getId()

Former Member
0 Kudos

I have no further idea. Please post the relevant view controller code.

Armin

Former Member
0 Kudos

I have tried with 2 options 1) setting visibility in doModify view

2) Setting in getVisibility method.

I guess doModify code is invalid so i am not posting it. Please see below code

1) I made visibility folder as singleton false

2) I assigned visibility node attribute(which has visibility property) to my custom colomn visibility property.


Z_Bw_Portal_Info_Input
        Output(ModelNode)
              Zsummary (Modelnode)
                   VisibilityTest(node with signleton true and 1:1 cardinality and selection)
                      ImageVisibility (Attribute with visibility property)
 
 public void wdDoInit()
  {
    //@@begin wdDoInit()
		wdThis.wdGetCalController().CalRFC();
    //@@end
  }


public com.sap.tc.webdynpro.progmodel.api.WDVisibility getVisibilityTestImageVisibility(IPrivateCalview.IVisibilityTestElement element)
  {
    //@@begin getVisibilityTestImageVisibility(IPrivateCalview.IVisibilityTestElement)
    
	IPrivateCalview.IZsummaryElement  Element = (IPrivateCalview.IZsummaryElement) element.node().getParentElement();
	
	int i = Element.index();
		if (i==10)
		  return WDVisibility.NONE;
		else
		  return WDVisibility.VISIBLE;
    
    //return null;
    //@@end
  }

Former Member
0 Kudos

Armin

Please see code posted my friend radha krishna (above posting) we are working on same issue.

Thanks

Former Member
0 Kudos

Set singleton=false!

Armin

Former Member
0 Kudos

Hi,

Why dont you add a value attribute of type visibility direclty under model node (Rows)

It works without any problems.

context structure is

Rows (model node)

-- Name (attribute, string)

-- EditorVisibility (attribute, type=Visibility)

Former Member
0 Kudos

Thanks a lot Armin. Every thing in code is ok but I have assigned visibility to both cell editor and column of that table. This created problems.

Once again thanks a lot for your time.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

The requirement is like this.

i wanted to setvisibility NONE or VISIBLE to a particular cell in the row based on the condition

if(getVisiblet is true)

{

ROW 1 : cel1 cel2 cel3(hide Cell3's Value)

}else

{

ROW 2: cel1 cel2 cel3(visibile Cell3's Value)

}

please help me so that i will be resolve my issue

Former Member
0 Kudos

Hi,

Please clearly tell your question. I havent get it.

Roshan

Former Member
0 Kudos

Hi,

Try this code:

For this code:

Node

-


Visible (Value Attribute) of type com.sap.ide.............visibility

(Set this attribute as the value of visibility property for the cell editor)

for (int i = 0; i < wdContext.<NODE>.size(); i++) {

wdContext.node<NODE>.moveTo(i);

if (condition)

wdContext.node<NODE>.currentNodeElement().setVisible(WDVisibility.VISIBLE);

else

wdContext.node<NODE>.currentNodeElement().setVisible(WDVisibility.NONE);

}

Former Member
0 Kudos

I don't understand your question. Can you please explain more clearly what you want to achieve?

Armin

Former Member
0 Kudos

Sorry for my unclear question. I want to set table cell editor visibility. I coded(as mentioned above) and executed . I am able to see that all celleditors are either hided or all are displayed. But based on conditions some cell editors have to be hided and some of them have to be displayed.

Please suggest me how to do it

Former Member
0 Kudos

One possibility: Use a calculated attribute. The generated getter has a parameter named "element" that denotes the node element for which the attribute value is calculated.

Example: The following method hides the editor in all rows with even index:

WDVisibility getRowsEditorVisibility(IRowsElement element)
{
  return element.index() % 2 == 0 ? WDVisibility.NONE : WDVisibility.VISIBLE;
}

Armin

Former Member
0 Kudos

Thanks for reply but i am not looking at hiding alternative table celleditor.

I want to hide cell editors based on some conditions.(which are application specific)

Former Member
0 Kudos

Hi,

You have to create a calculated attribute and do the application specific code in that

For ex:

public com.sap.tc.webdynpro.progmodel.api.WDVisibility getHierarchyRootVisibility(IPrivateMainView.IHierarchyRootElement element)

{

//@@begin getHierarchyRootVisibility

if(element.getIsLeaf() ) // put your application specific code here

return WDVisibility.VISIBLE;

return WDVisibility.NONE;

//@@end

}

and bind this to the visibility of the respective fields

Regards

Ayyapparaj

Former Member
0 Kudos

Hi,

create the "visible" value attribute of type "com.sap.ide.webdynpro.uielementdefinitions.Visibility"

<b>under the table node</b>.

But then what i have observed is that the row whose visiblity is set to NONE will still show in the table, but without any data.

If the row data is not necessary you can remove the element from the node.

IPrivate(your view).ITableNodeElement ele =wdContext.nodeTableNode.getTableNodeElementAt(i);

wdContext.nodeTableNode.removeElement(ele);

Message was edited by:

Shriram Kabra

Former Member
0 Kudos

Hi Armin

I want to set visibility of some cell editors based on other column values. For example my table structure is


Col1                             |    Col2
------------------------------------|-------
Col1 row1                      |    Col2 row1
Col1 row2                      |    Col2 row2

Col1 is from model node and Col2 is custom column in table (which I created in view layout using "create grouped Column" option . If Col1 row1 ==0 then Col2row1 should not be visible and if Col1 row1!=0 then Col2 row1 should be visible.

Similarly for all rows in table. Please suggest me how can I do it

Former Member
0 Kudos

Hi,

I also faced this problem. I think this is due to your node which is a model node. Create a context node. When you get result in a model node, try to copy it in this context node and bind this node with the table.

Thanks

Former Member
0 Kudos

Look again at my sample code and just replace

element.index() % 2 == 0

by

your_condition( element );

Armin

Former Member
0 Kudos

Hi Armin

I followed same steps and I used element.index() % 2 == 0 condition for testing purpose. Result is, if IF condition is true all elements in all rows are visible (Col row1 and Col2 row1) and if IF condition is false all are rows are invisible.

My context struecture is


Rows (model node)
-- Name (attribute, string)
-- Additional (value node, card=1:1, selection=1:1, singleton=false)
---- EditorVisibility (attribute, type=Visibility)

Is there any thing to do with context structure or cordinatlity?

Former Member
0 Kudos

Probably your code does not set the "EditorVisibility" attribute correctly. The singleton=false means that there exists a node "Additional" for each <b>element </b>in node "Rows".

To set its value, you have to write code like

IRowsElement row = ...;
row.nodeAdditional().currentAdditionalElement().setEditorVisibility(value);

Armin

Former Member
0 Kudos

Thanks you very much for your responce in this thread. I am giving my code below. Please look at it.

What ever the condition I am writting its applicable only for first row. I am able hide first row cell editor based on condition but not other rows.

1)I have set node as singleton and cordinality, selection as 1:1.

2) I assigned that visibility attribute to my coloum cell editor property.

3) in doModify method I have written below code.



for (int i = 0; i < wdContext.nodeRows().size(); i++) {				
IPrivate<View>.IAdditionalElement v =
   wdContext.nodeAdditional().currentAdditionalElement();			

IPrivate<View>.IRowsElement row =wdContext.nodeRows().getRowsElementAt(i);
v.setEditorVisibility (
	(row.id() ==0 )? WDVisibility.NONE: WDVisibility.VISIBLE);		
}

4) I tried same code in getVisibility method as metioned but i am getting same result.

Former Member
0 Kudos
for (int i = 0; i < wdContext.nodeRows().size(); i++) 
{				
IPrivate<View>.IAdditionalElement v =
   wdContext.nodeAdditional().currentAdditionalElement();			
 
IPrivate<View>.IRowsElement row =wdContext.nodeRows().getRowsElementAt(i);
v.setEditorVisibility (
	(row.id() ==0 )? WDVisibility.NONE: WDVisibility.VISIBLE);		
}

Replace by:

for (int i = 0; i < wdContext.nodeRows().size(); i++) 
{				
  IPrivate<View>.IRowsElement row = wdContext.nodeRows().getRowsElementAt(i);
  IPrivate<View>.IAdditionalElement v = row.nodeAdditional().currentAdditionalElement();
  v.setEditorVisibility (
	(row.id() ==0 )? WDVisibility.NONE: WDVisibility.VISIBLE);		
}

Armin