mercredi 1 juin 2016

How to bind a checkbox in jquery datatabe row using angular

I have below functions in same angular controller. $scope.init() is used to configure a Jquery datatable. In first column I have checkbox and I need to call toggleSelection() on checkbox change/toggle and pass an object id. However, I am not able to do so.

$scope.init = function {
 var testTable = $('#testTable').dataTable($.extend({
    aaSorting:[[5, 'desc']],
    fnRowCallback: function (nRow, object, iDisplayIndex){
          //some code to format rows
    },
    aoColumns: [{
                mData: "id", sTitle: "", bSortable: false,
                mRender:function(data, type, question){
                return '<input type="checkbox" ng-click="toggleSelection(' + object.id + ')"/>';
    }},
    //....Other columns
    ],
    fnServerData: TestApiHandler
    }, defaultTableSettings))

    //TestApiHandler: Already configured for Ajax call
    //defaultTableSettings: dafault setting for datatable
}

$scope.toggleSelection = function(id) {
    console.log('Object Id' + id)
}

Below is HTML for datatable.

<table id="testTable" class="table table-bordered table-condensed table-striped table-hover "></table>

I am new to Angular and still learning. Any help will be appreciated. Please let me know if anything is not understood.

Thanks




Aucun commentaire:

Enregistrer un commentaire