cancel
Showing results for 
Search instead for 
Did you mean: 

How to highlighted some of the rows of table to bold dynamically

Former Member
0 Kudos

Hi,

I am fetching data and displaying in table .My requirement is i have to make some of the rows bold based

on condition.I did like below.

1.I created model and bind that model into custom controller ,it created one input model node and one out put node.

2.I mapped model node from custom context to view context.

3.In view context I created model node already created during context mapping from custom context to view context.I created one Value attribute in view context made calculate true and type is TextViewDesign and read only property true.In table's Text view's design property I set to what value attribute i created .In view

implementation's setter method i wrote the following code.

public com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign getCalculateTest(IPrivateResultView.IContextElement element)

{

//@@begin getCalculateTest(IPrivateResultView.IContextElement)

int n = wdContext.nodeBirthdaylist().size();

for(int i=0;i<n;++i){

if(wdContext.nodeBirthdaylist().getBirthdaylistElementAt(i).getEmail_Id()!=null){

return (WDTextViewDesign.EMPHASIZED);

}

else{

return(WDTextViewDesign.EMPHASIZED);

}

//element.

}

//@@end

}

it is showing error that method should return WDTextViewDesign type.Is above code is correct.

Thanks & Regards

muna

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Hi mukesh,

I already did that and what ever the code i send ,i wrote in getter method.

Thanks & Regards

muna

Former Member
0 Kudos

Hi mukesh,

I created one value attribute in ResultView(Table view) Context and when i am trying select value for type property from Dictionary Simple type ,com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign option is not comming.

Thanks & Regards

muna

Former Member
0 Kudos

Hi

You can select it from type com.sap.ide.webdynpro.uielementdefinitions.TextViewDesign

Kind Regards

Mukesh

Former Member
0 Kudos

Hi LM,

Thanks for your suggestion ,I tried your solution but i am facing same problem.

Thanks & Regards

muna

Former Member
0 Kudos

Hi

Create an attribute with type com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign

in the Table node and bind it to that textview's design property and set the value according to your conditions.

if(myValues.getBirthdaylistElementAt(idx).getEmail_Id()!=null && !myValues.getBirthdaylistElementAt(idx).getEmail_Id().equals(""){

wdContext.currentBirthdaylistElement().set<Param>(WDTextViewDesign.EMPHASIZED);

}

Kind Regards

Mukesh

Former Member
0 Kudos

Hi VS,

My code is

public com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign getBirthListCalculate(IPrivateResultView.IBirthListElement element)

{

//@@begin getBirthListCalculate(IPrivateResultView.IBirthListElement)

IBirthdaylistNode myValues =wdThis.wdGetBAL_EP_HR_BirthDayCustController().wdGetContext().nodeOutput().nodeBirthdaylist();

int idx = element.index();

if(myValues.getBirthdaylistElementAt(idx).getEmail_Id()!=null){

return WDTextViewDesign.EMPHASIZED;

}

else{

return WDTextViewDesign.LABEL;

}

//@@end

}

It is making all the records EMPHASIZED,It is not working based on the condition that if email id is not null record should be emphasized otherwise it should be lable.

Thanks & Regards

muna

lajitha_menon
Contributor
0 Kudos

Hi,

Try this in the corresponding line,

if(myValues.getBirthdaylistElementAt(idx).getEmail_Id()!=null && !myValues.getBirthdaylistElementAt(idx).getEmail_Id().equals(""){

Former Member
0 Kudos

Where in the context did you add the attribute "BirthListCalculate"? You have to add it (and perhaps name it more properly) under the data source node of the table, not under the context root node.

Assuming the following view controller context structure


- Birthdaylist (model node, mapped to custom controller)
  - Email_Id (attribute)

change it to:

- Birthdaylist (model node, ...)
  - Email_Id (attribute)
  - Decoration (value node, cardinality 1:1, selection 1:1, singleton=false)
    - TextDesign (attribute, DDIC type TextViewDesign, calculated=true, readOnly=true)

Implement the getter like

WDTextViewDesign getDecorationTextDesign(IDecorationElement element)
{
  IBirthdaylistElement birthday = (IBirthdaylistElement)element.node().getParentElement();
  return birthday.getEmail_Id() != null
    ? WDTextViewDesign.EMPHASIZED
    : WDTextViewDesign.LABEL;
}

Armin

Former Member
0 Kudos

Hi VS,

value variable is not declared .Can you tell me which type value variable is.

Thanks & Regards

muna

Former Member
0 Kudos

Muna,

Use WDTextViewDesign instead of "value", like WDTextViewDesign.LABEL

Former Member
0 Kudos

Hi VS,

Is it correct,I created one calculate value attribute

under Birthdaylist node(This node is providing data)and I made the read only property to false.In setter and getter method I put the code lilk below.

public void setBirthListCalculate(IPrivateResultView.IBirthListElement element, com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign value)

{

//@@begin setBirthListCalculate(IPrivateResultView.IBirthListElement, com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign)

IBirthdaylistNode myValues =wdThis.wdGetBAL_EP_HR_BirthDayCustController().wdGetContext().nodeOutput().nodeBirthdaylist();

com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign design=null;

int n = myValues.size();

for(int i=0;i<n;++i){

//return (myValues.getBirthdaylistElementAt(i).getEmail_Id()!=null)? WDTextViewDesign.EMPHASIZED : WDTextViewDesign.EMPHASIZED;

if(myValues.getBirthdaylistElementAt(i).getEmail_Id()!=null){

element.setCalculate(value.EMPHASIZED);

}

else{

element.setCalculate(value.LABEL);

}

}

//@@end

}

public com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign getBirthListCalculate(IPrivateResultView.IBirthListElement element)

{

return element.getCalculate();

}

Is above code is correct but it is giving stack over flow exception.

Thanks & Regards

muna

Former Member
0 Kudos

Muna,

There are should be no setter at all (mark attribute as read-only). Put the following in getter:


public com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign getBirthListCalculate(IPrivateResultView.IBirthListElement element)
{
  IBirthdaylistNode myValues = 
    wdThis
      .wdGetBAL_EP_HR_BirthDayCustController()
        .wdGetContext()
          .nodeOutput()
            .nodeBirthdaylist();

    int idx = element.index();

    if ( myValues.getBirthdaylistElementAt(idx).getEmail_Id()!=null )
      return value.EMPHASIZED;

    else
      return value.LABEL;

}

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Message was edited by: Valery Silaev

Former Member
0 Kudos

Hi Mukesh,

Thanks a lot for your immediate reply.Now it is not showing error but i am giving condition if email id is not null font of text should be emphasized otherwise it should be label,i mistakely mentioning emphasize both for

if and else part.I changed from emphasized to lable in else part but for all only emphasized color is comming.That means empahsized color of font is comming for all records even if mail id may or may not exist.So how i will fix it .

Thanks & Regards

muna

lajitha_menon
Contributor
0 Kudos

Hi,

I suggest the following.

Under Node Birthdaylist(node from where your data for the table is coming), create a value attribute (instead of creating in the context). For this value attribute, calculate text view design based on currentElement value.

Set the property against this value attribute.

Cheers,

LM

Former Member
0 Kudos

Small correction:

instead of <i>For this value attribute, calculate text view design based on currentElement value</i>

use <i>For this value attribute, calculate text view design based on parameter <b>element</b> value</i>

VS

Former Member
0 Kudos

Hi

Try this

public com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign getCalculateTest(IPrivateTestEVSView.IContextElement element)

{

// @@begin getCalculateTest(IPrivateResultView.IContextElement)

com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTextViewDesign design=null;

int n = wdContext.nodeBirthdaylist().size();

for(int i=0;i<n;++i){

if(wdContext.nodeBirthdaylist().getBirthdaylistElementAt(i).getEmail_Id()!=null){

design=(WDTextViewDesign.EMPHASIZED);

}else{

design=(WDTextViewDesign.EMPHASIZED);

}

// element.

}

return design;

// @@end

}

Kind Regards

Mukesh