auto select while loading the table
auto select while loading the table
carloawpogi
Posts: 2Questions: 2Answers: 0
Hi I just want to auto select rows in my tables came from my array
function SuccessSearch(result) {
$("#lstApprv").empty();
var parsed = JSON.parse(result);
var arr = [];
for (var x in parsed) {
$('#lstApprv').append('<option value="' + parsed[x] + '">' + parsed[x] + '</option');
}
}
after inputting it into ListBox
i also want it to auto select from my datatables
here is my table code
table = $('#carl').DataTable({
destroy: true,
ordering: true,
searching: true,
processing: false,
sScrollX: "100%",
select: {
style: 'multi'
},
ajax: function (data, callback, settings) {
var out = [];
for (var x in newJson) {
out.push(newJson[x]);
}
var total = out.length;
setTimeout(function () {
callback({
draw: data.draw,
data: out,
recordsTotal: total,
recordsFiltered: total
});
}, 50);
},
scrollY: 340,
scroller: {
loadingIndicator: true
},
columns: [
{ data: "EMPNO" },
{ data: "LNAME" },
{ data: "FNAME" },
{ data: "POSITION_NAME" },
]
});
This discussion has been closed.
Answers
Your questions are not really clear.
are you trying to use a select box to cause matching fields on the datatable to be come selected? Or are you trying to set rows selected as the datatable initializes?
Also, some of the code in your ajax is for serverSide:true but I don't see it anywhere so you probably can simplify the ajax (you don't need draw, recordTotal, etc if you are returning all of the data at once)
and why the set timeout?