2014-07-25 73 views
-1

我需要給背景添加列,並使用javascript和css更改UI5中表格的字體樣式。 我需要知道如何將CSS應用到特定元素。 我該怎麼做?在你的表或列等。無論您想SAP UI5中的樣式表

+0

通過addclass()方法爲表提供一個類,並像往常一樣做任何你想做的事情css – Roshan

回答

1

添加類爲

oTable.addStyleClass("classname"); 

使用CSS像往常一樣

.classname{ 
color:red 
} 

,包括index.html中

此css文件基於您的評論:將id添加到表格標題列中以這種方式使用它

var oColumn = new sap.ui.table.Column("tc",{ 
    label: new sap.ui.commons.Label({text: "Last Name"}), 
    template: new sap.ui.commons.TextView().bindProperty("text", "lastName"), 
    sortProperty: "lastName", 
    filterProperty: "lastName", 
    width: "200px" 
}); 

這裏id=tc被添加到此標題。

寫CSS,因爲你需要

#tc{ 
color:red 
} 

SEE DEMO HERE

+0

感謝您的幫助Roshan ...我真正想做的是給表中的行使用css中的第n個孩子的alterbate顏色...我如何給行中的特定CSS的oTable中的類/目標行。 .. –

+0

你可以通過像往常一樣只添加CSS。請參閱http://jsfiddle.net/Vq5ed/ – Roshan

+0

感謝好友... gr8幫助..但如何設置標題的樣式,即列標題... tr和td工作正常......這是行不通的...我該怎麼做? –

0

================== XML ========== =========================

=================== format js ===========================

yaoji.utils.formatter.format = function (cellValue) { 
    this.onAfterRendering= function() { 
    //!!! if not after redering, can't get the dom 
     var cellId = this.getId(); 
     $("#"+cellId).parent().parent().parent().css("background-color","red"); 
    return cellValue; 
};