2014-07-25 64 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; 
};