Skip to Content

How to change style class of td in table

Hi Experts,

In SAPUI5, there is no APIs to change anything of the table cell itself.

The following code is aimed to modify the style of the td cell and control in the cell, but both of them adds style class to the control, not td cell.

Could anyone indicate how to change td cell style in a table?

editableFormatter: function(v, control) {

if(sap.ui.getCore().byId("btnEdit").getText()==="Edit") {

control.getParent().getCells()[2].addStyleClass('readonly');

control.addStyleClass('readonly');

}

}

The top one is what I need by modifying html in debug tool.

The bottom one is current implementation.

B.R.

Mingquan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Aug 25, 2015 at 03:51 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 26, 2015 at 04:35 AM

    Dear all,

    I found the td id is like this: id="oTable-rows-row0-col2", could I use jquery to add style class to td like this $('#'+table.getId()+'-rows-row'+i+'-col'+idx).addClass('readonly')?

    Array of data in table is in place and column index is given.


    for(var i = 0, j = parameters.length; i < j; i++) {

    pr = parameters[i];

    if(pr.modifiable)

    $('#'+table.getId()+'-rows-row'+i+'-col'+idx).removeClass('readonly');

    else

    $('#'+table.getId()+'-rows-row'+i+'-col'+idx).addClass('readonly');

    }


    Any risks and any suggestions?


    B.R.

    Mingquan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 26, 2015 at 03:43 AM

    Hi Mike,

    If you're using sap.ui.table.Table control. Will this work? - JS Bin - Collaborative JavaScript Debugging

    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.