Skip to Content
0
Former Member
Apr 08, 2013 at 12:56 PM

toggleStyle on textView based on modelData

32 Views

I have at table based on a JSONModel, where the cells are textViews.

oTable.addColumn(new sap.ui.table.Column({          label: new sap.ui.commons.Label({text: "Realiseret"}),          template: new sap.ui.commons.TextView({              id : "st_status_txt",              design: sap.ui.commons.TextViewDesign.H1,              textAlign: sap.ui.core.TextAlign.Center}).bindProperty("text", "status").addStyleClass("larger"),          }));

The model gets filled by an AJAX call.

var modelAPI = "/crm-slt/xs/xsWinback/services/crm_dashboard4.xsodata/dashboard4?$format=json&$select=Version,Tabt,Winback&$filter=CALMONTH%20eq%20'" + filterMonth + "'";      $.get(modelAPI, function(data){          //alert(data.toString());          oModelMonth.setData(loadModel(data));  // alter style based on model      });

so far

I would like to alter the styleClass based on the content of the cell.

I if "status" is negativ then largerRed if positiv "largerGreen" if 0 the just "larger".

Which changes the background color.

I have been trying to get the text field itself.

I can do it by regular jQuery :

$("st_status_txt-row0-cell0")

but this cant use toggleStyleClass.

then i tried to use the sap library.

sap.ui.getCore().byId("st_status_txt-row0-cell0")

but using this method I just get "Undefined".

My problem is getting the textView control, does any body know how i can achieve this?

Attachments

table.jpg (8.9 kB)