How do get all data in a row DataTables ?
How do get all data in a row DataTables ?
headshot9x
Posts: 59Questions: 16Answers: 1
Hello guys . I have a DataTable with source JSON string via Ajax .I can load data into DataTable , and i want to get data of row when click .Please see DataTables debugger at http://debug.datatables.net/idihol
Add more detail , in my page Test.aspx
<table id="div_table" class="display cell-border compact" width="100%">
<thead>
<tr>
<td>No</td>
<td>Name</td>
<td>Des</td>
<td>LID</td>
<td>AID</td>
<td>DATE</td>
<td>BY</td>
</tr>
</thead>
</table>
And this is my script . I use lasted DataTable 1.10.6
var table = $('#div_table').DataTable({
"processing": false,
"serverSide": false,
"ajax": {
"url": "../BUS/WebService.asmx/LIST_LOCATION",
dataSrc: function (json) {
return $.parseJSON(json.d);
},
"dataType": "json",
"contentType": "application/json; charset=utf-8",
"type": "POST"
},
"aoColumns": [ //// 7 columns as Datatable
{ "mData": null, "aTargets": [0], "sType": "integer", "bSearchable": false, "orderable": false },
{ "mData": "LOCATION_NAME", "aTargets": [1], "sType": "string" },
{ "mData": "LOCATION_DES", "aTargets": [2], "sType": "string" },
{ "mData": "LOCATION_ID", "aTargets": [3], "sType": "string", "bVisible": false, "bSearchable": false, "orderable": false },
{ "mData": "AREA_ID", "aTargets": [4], "sType": "string", "bVisible": false, "bSearchable": false, "orderable": false },
{ "mData": "EDIT_DATE", "aTargets": [5], "sType": "date", "bVisible": false, "bSearchable": false, "orderable": false },
{ "mData": "EDIT_BY", "aTargets": [6], "sType": "string", "bVisible": false, "bSearchable": false, "orderable": false }
],
"order": [[1, 'asc']]
});
////table.columns([3, 4, 5, 6]).visible(false); //// disable column 4,5,6,7
//// create index column 1
table.on('order.dt search.dt', function () {
table.column(0, { search: 'applied', order: 'applied' }).nodes().each(function (cell, i) {
cell.innerHTML = i + 1;
});
}).draw();
$('#div_table tbody').on('click', 'tr', function () { // get full data or some columns at row selected
$(this).toggleClass('selected');
var data_ = table.row($(this)).data();
alert(data_[3] + " and " + data_[4]);
/// alert(table.row($(this)).data()); error it show info "object object"
});
Run it, i get error "undefined and undefined"
Can you tell me and give me some advice.Thank , headshot9x.
This discussion has been closed.