Skip to Content

How to change styles of cells in sap.ui.table.Table

Styles of cells in sap.ui.table.Table can be changed by


changing style class names (whose are preliminary defined in css file)

in corresponding properties of table model (see oModelObject.styleClassName[j] below)

and then applying them to corresponding table cells (see aCells[j].addStyleClass below) in following way:


oTable = sap.ui.getCore().byId(sTableId);
if (oTable) {
     aRows = oTable.getRows();
     if (aRows && aRows.length > 0){
          for (i = 0; i < aRows.length; i++) {
               oModelObject = aRows[i].getBindingContext().getObject();
               aCells = aRows[i].getCells();
               if (oModelObject && aCells && aCells.length > 0) {
                    for (j = 0; j < aCells.length; j++) {
                         aCells[j].addStyleClass(oModelObject.styleClassName[j]);
                    }
               }
          }
     }
}
Be the first to leave a comment
You must be Logged on to comment or reply to a post.