我想获得Datatables列的价值。这是我的数据表脚本:
$(function () {
$('#kategoriTable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": true,
"scrollX": false,
"ajax": {
"url" : "kugi/getDataKategori",
"dataSrc" : function(json) {
console.log(json);
return json.ProposalCategories
}
},
"columns": [
{ "data": "CategoryId"}, // I want to get this value, and then use it to edit the data
{ "data": "Name"},
{ "data": "Code"},
{ "data": "TypeName"},
{ "data": "IsAbstract"},
{ "data": "DefSrcOrganisationName"},
{ "data": null,
"bSortable": false,
"mRender": function (o) { return '<a href="kugi/edit_usulan_kategori/"><button class="btn btn-success btn-xs">Edit</button></a>'; }
}
]
});
});
之后我想将此值发送到此代码
return '<a href="kugi/edit_usulan_kategori/XXXX"><button class="btn btn-success btn-xs">Edit</button></a>'
如何获取CategoryId
的值,然后将其放入XXXX
?
先谢谢。
答案 0 :(得分:1)
即将结束 - 您实际上可以通过<script>
app.controller('OrderController', function ($scope, $http) {
$scope.quantity = 1;
$scope.Orders = {};
var tst ;
GetOrders = function () {
$http.get('/Order/GetAllOrders').success(function (response) {
$scope.Orders = response;
//here i set tst, and tst has value, i checked it has value and it's not undefined
tst = response;
});
}
GetOrders();
GetTotalValueOfProducts = function () {
//but here 'tst' is undefined!!!
var p = tst;
}
GetTotalValueOfProducts();
});
</script>
参数访问所有列值:
row
此处的文档 - &gt;的 https://datatables.net/reference/option/columns.render 强>