'datatable sort works , but button does not updates

    <div class="card-block">
        <div class="table-responsive dt-responsive">
            <table id="datatables" class="table table-bordered table-striped table-condense table-hover table-statement cf" cellspacing="0" width="100%">
                <thead class="thead-inverse cf">
                <tr>
                    <th></th>
                    <th>{{ t('Paper') }}</th>
                    <th>{{ t('subject') }}</th>
                    <th>{{ t('Date Published') }}</th>
                    <th>{{ t('author') }}</th>
                    <th>{{ t('Total No Of Purchases') }}</th>
                    <th>{{ t('Price(WS)') }}</th>
     
                    <th>{{ t('action') }}</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>

Below is script code

$(document).ready(function () {
            $('#datatables').CustomDataTable({


            "data": function (d) {
                return $.extnd({}, d, {
                    "filter": [
                        ["paper.question_subject_id","=",$("#subject_id").val()],
                        ["subjectLevel.level_id","=",$("#level_id").val()],
                        ["paper.name","like",$("#paper_name").val()],
                        ["user.name","like",$("#author").val()],
                    ]
                });
            },


            "dataSrc": function (json) {
            console.log(json);
                {{ partial('../../shared/views/partials/js/datatable_datasrc_declare') }}
                for (var i = 0; i < json.data.length; i++) {

                    if(json.data[i]['7'] == ''){
                        json.data[i][col_action] = '<div class="btn btn-primary pull-right buy" onclick="myFunction(' + json.data[i]['number'] + ')"><i class="fa fa-shopping-cart"></i> {{ t('purchase') }}</div> ';
                    }else{
                        json.data[i][col_action] = '<a class="btn btn-info pull-right" href="/{{ module_name }}/bookshelf/result/' + json.data[i]['8'] + '"><i class="fa fa-edit"></i> {{ t('do_paper') }} </a> ';
                    }
                    json.data[i][col_action] += '<a class="btn btn-info btn-sm" href="{{ '/' ~ module_name ~ '/' ~ controller_name }}/view/' + json.data[i][0] + '">{{ t('details') }} </a> ';
                }
                return json.data;
            }

        });


    });

What i am facing right now is : When i tried to table sort ( the data show correctly ) the information is up-to-date after sort , but json.data[i][col_action] does not update by filter. and there is no error appears , just the button did not get updated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source