我有一个进行服务器端处理的angular-datatable,但我想控制一切。我在服务器内部执行的操作是获取从前端传递到服务器的标头,然后根据标头的值操作数据库。我遇到的问题是,我不知道如何单击数据表的分页时,替换标题的值。分页没有点击事件,因为它是由angular-datatable处理的。
function formatRequest(successCallback, errorCallback, sortByField, sortByType, pageNumber, resultLimit) {
var request = {
method: 'GET',
url: 'http://mylocalhost:987/api/form-templates',
headers: {
'X-PageNumber': pageNumber || 1,
'X-ResultLimit': resultLimit || 2,
'X-SortByField': sortByField || 'LastUpdated',
'X-SortByType': sortByType || 'desc'
},
data: function(data){
//is there a way I can replace the values of headers I created, here?
},
dataSrc: function(response){
var data ={};
data.draw = response.pageNumber;
data.data = response.results;
data.recordsTotal = response.results.length;
data.recordsFiltered = response.results.length;
return data.data;
}
};
var options = DTOptionsBuilder
.newOptions()
.withOption('processing', true)
.withOption('serverSide', true)
.withOption('ajax', request)
.withDataProp(function(response){
var data ={};
data.draw = response.pageNumber;
data.data = response.results;
data.recordsTotal = response.results.length;
data.recordsFiltered = response.results.length;
return data.data;
})
.withPaginationType('full_numbers');
return options;
}