Missing Individual column searching (select inputs) when using REST API
Missing Individual column searching (select inputs) when using REST API
Dear All,
I had written the below code to fetch the data from SharePoint list and bind to Jquery Data table.
But my table is not having any **Individual column searching (select inputs) options .
I tried adding column.data().unique().sort().each(function (d, j) {select.append('<option value="' + d + '">' + d + '</option>')
after **table.rows.add($(tableHTML)).draw() **& **return dfd.promise(), But I find no luck.
Can any one please do let me know where the exact location put append the unique and sort functions
getJSONDataFromUrl(nextUrl).done(function (listItems) {
TotalItemCount = TotalItemCount+listItems.d.results.length;
var items = listItems.d.results;
var next = listItems.d.__next;
$.when(processList(next,ItemCount)).done(function (){
dfd.resolve();
});
var tableHTML='';
//Create datatable object
var table = $('#table_id').DataTable();
$.each(items, function(index, obj){
var tr = $('<tr>');
var ID=obj.ID;
var td = $('<td>');
td.append(ID);
tr.append(td);
var Country=obj.Country;
var td = $('<td>');
td.append(Country);
tr.append(td);
var City=obj.City;
var td = $('<td>');
td.append(City);
tr.append(td);
var Profession=obj.Profession;
var td = $('<td>');
td.append(Profession);
tr.append(td);
table.rows.add($(tr)).draw(); //Append each list row to data tabel
});
// table.rows.add($(tableHTML)).draw(); //Append each list row to data tabel
});
return dfd.promise();
}
Answers
Hi @beginner_2018 ,
This page here may help : it discusses adding rows.
The first thing to change is line 43, you're adding a single row but you're using the plural function
rows.add()
- the one to use isrow.add()
.Cheers,
Colin