How to add checkbox to DataTables with Data provided by Object

How to add checkbox to DataTables with Data provided by Object

ShaibaazSShaibaazS Posts: 7Questions: 3Answers: 0

Dear Sir,
First of all I like the functionality DataTables provide, Thank You Allan Sir.
I am trying to populate a DataTable with Object from server-side using ajax .
I am able to populate the DataTable with Object Data, But how can I add a Check Box in the first column of DataTable. I am referring to the following examples :
"https://datatables.net/extensions/select/examples/initialisation/checkbox.html"
"https://datatables.net/extensions/fixedcolumns/examples/integration/select-checkbox.html"

Following is my code:
//////////////////////////// JS Section \\\\\\\\\\\\\\\
$.ajax({
type: "POST",
url: "abc.aspx/xyz",
data: '{name:"' + agentName + '"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {

                    var tblParent = $('#tblTest').DataTable({
                        destroy: true,
                        select: true,
                        data: response.d,
                        columns: [
                            { 'data': 'ID' },
                            { 'data': 'EnquiryID' },
                            { 'data': 'InvoiceDate' },
                            { 'data': 'ReferenceNo' },
                            { 'data': 'JobNo' },
                            { 'data': 'PurchaseInvoiceNo' },
                            { 'data': 'LedgerName' },
                            { 'data': 'FCName' },
                            { 'data': 'FCPendingAmount' },
                        ],
                        columnDefs: [{
                            orderable: false,
                            className: 'select-checkbox',
                            targets: 0
                        }],
                        select: {
                            style: 'os',
                            selector: 'td:first-child',
                        },
                        order: [[1, 'asc']],
                    });
                },
                error: function () {
                    alert('Error');
                },
            });

/////////////////////////////////////End Of JQuery Section \\\\\\\\\\\\\\\
///////////////////////////////////////Html Section\\\\\\\\\\\\\\\\\\\

<%--<tr style="color: white; background: #33b770;">--%>
ID Enquiry ID Invoice Date Ref No Job No Purchase InvoiceNo Ledger Name FC Name FC Pending Amount

//////////////////////////////////////End OfHtml Section\\\\\\\\\\\\\\\\\\\
Hope to see a solution or a hint atleast.
Happy Coding!!

This discussion has been closed.