How to Update a button's text which is situated in a collection of button?

How to Update a button's text which is situated in a collection of button?

pesce11pesce11 Posts: 8Questions: 2Answers: 0

I have a table which shows the product-orders and their status, the data arrive from db.
The table has a collection of buttons called [Action control] which comprises three action buttons[show list, add note, and rejected]
What I want to do is that after the table has been loaded correctly; if there exists any rejected-order the text of the button should update showing the number of rejected-orders as a notification concatenated to its original text [Rejected]
let me share a direct link: http://5.157.96.119:10088/dttest/dttest2.html
in the test link there are 4 collection buttons [actions-control, doc-control, col-vis, phases]
On clicking the rejected button it open a dialog box[containg list of rejected orders] for further actions,{which works fine} and in the sup tag [0] is by default, As in the table there is a rejected line indicated with red color [according to its css class(.rejected) from db]
using createdRow callback ftn:
<code>
"createdRow": function( row, data, dataIndex ) {//check on creation of row if rejected, modified or updated
if ( $( row ).find('td:eq(0) >input').hasClass('rejected')/data[24] == "N"/ ) {//used in phase 1,2 and 3
$(row).addClass( 'pink' ).attr('title', 'This line has been rejected by admin.');
}//
if ( $( row ).find('td:eq(0) >input').hasClass('modified') ) {//used only in phase 3
++rejectedNum;
$(row).addClass( 'pink' ).attr('title', 'This line has been Modified/rejected by admin.').find('td:eq(0) >input').attr({disabled:'disabled', title:'Disabled for milano'}).remove();

            }
            if ( $( row ).find('td:eq(0) >input').hasClass('updated')/*data[24] == "N"*/ ) {//used in phase 1,2 and 3
                $(row).addClass( 'lightgreen' ).attr('title', 'Client has updated this line.');
            }
        }

</code>
I have tried initComplete callback ftn of DT but still wasn't successful in updating the text of rejected button.
I also tried drawCallback.
Really need help now

This question has an accepted answers - jump to answer

Answers

  • pesce11pesce11 Posts: 8Questions: 2Answers: 0

    This is the screen-shot in which rejected button functionality is shown:
    https://d.pr/rHGN

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    edited November 2016

    The button-selector documentation describes how you can use a selector with the button() method to select a button (then use button().text() to modify the text).

    Allan

  • pesce11pesce11 Posts: 8Questions: 2Answers: 0
    edited November 2016

    Thank you Allan for a quick response, but the problem is that the mentioned button is inside a collection button, as shown in the image below:
    https://d.pr/rHGN
    I tried with table.button( 0 ); which is collection button [Actions-control] not the rejected button and I dont know how the DT keeps the references of buttons inside a collection button.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓

    Sorry - my link above to the button-selector documentation had a typo in it. I've correct it now. That details how to get sub-buttons - specifically use 0-0, 0-1, etc.

    Allan

This discussion has been closed.