然后当我点击数据表中的按钮或标签时,打开模态两次,ajax运行两次。
PS。我使用angular.js所以datatables是指令。但是数据表不是角度数据表。指令由jquery datatables完成。
如何解决此问题?
谢谢你的回答。
这是我的来源。
1.datatable column render
/**
* datatable
*/
$scope.grid = {};
$scope.grid.dtInstance = {};
$scope.grid.dtColumns = {
columnDefs: [
{
"targets": 1,
"render": function ( data, type, row ) {
var return_value = siteInfo[row.site_code].name+"<br>"+row.site_id;
return return_value;
}
},
{
"targets": 2,
"render": function ( data, type, row ) {
return row.order_code;
}
},
{
"targets": 3,
"render": function ( data, type, row ) {
return commonSVC.getDate(row.wdate, 'yyyy-MM-dd HH:mm:ss');
}
},
{
"targets": 4,
"render": function ( data, type, row ) {
return row.status;
}
},
{
"targets": 5,
"render": function (data, type, row) {
return row.prod_code;
}
},
{
"targets": 6,
"render": function (data, type, row) {
return row.delivery_vendor;
}
},
{
"targets": 7,
"render": function (data, type, row) {
return row.order_name;
}
},
{
"targets": 8,
"render": function (data, type, row) {
return row.to_name;
}
},
{
"targets": 9,
"render": function (data, type, row) {
return row.to_address;
}
},
{
"targets": 10,
"render": function (data, type, row) {
return row.count;
}
},
{
"targets": 11,
"render": function (data, type, row) {
return row.price;
}
},
{
"targets": 12,
"render": function (data, type, row) {
return row.deli_cost;
}
},
{
"targets": 13,
"render": function (data, type, row) {
var return_value = row.deli_corp+"<br>"+row.deli_invoice;
return return_value;
}
},
{
"targets": 14,
"render": function (data, type, row) {
var type = "shipment";
var toDeleteStr = row.number+','+"'"+row.order_code+"'";
return '' +
'<ul class="icons-list">' +
'<li class="dropdown">' +
'<a href="#" class="dropdown-toggle" data-toggle="dropdown" >' +
'<i class="icon-menu9"></i>' +
'</a>' +
'<ul class="dropdown-menu dropdown-menu-right">' +
'<li><a ng-click="open_detail(\'' + type +'\',\'' + row.number +'\')">상세</a>' +
'<li><a ng-click="deleteDo('+toDeleteStr+')">삭제</a>' +
'</ul>' +
'</li>' +
'</ul>';
}
}
],
fnRowCallback: function (nRow) {
$compile(nRow)($scope);
}
};
datatable option
$scope.grid.dtOptions = {
"serverSide": true,
"ajax": {
"url": settings.apiUrl + "/api/order/shipmentList",
"data": function ( d ) {
var data = angular.merge({}, d, $scope.searchForm);
data.orderby = 'number desc';
var search_date = data.search_date.split(" ~ ");
data.sdate = search_date[0];
data.edate = search_date[1];
return JSON.stringify(data);
},
"dataSrc": function(json){
$scope.status_total = json.status_total;
$scope.status_map_total = json.map_total;
$scope.status_total1 = json.status["신규주문"] ? json.status["신규주문"].total:0;
$scope.status_total2 = json.status["출고대기"] ? json.status["출고대기"].total:0;
$scope.status_total3 = json.status["보류"] ? json.status["보류"].total:0;
$scope.status_total4 = json.status["출고완료"] ? json.status["출고완료"].total:0;
$scope.status_total5 = json.status["배송중"] ? json.status["배송중"].total:0;
$scope.status_total6 = json.status["수취확인"] ? json.status["수취확인"].total:0;
$scope.status_total7 = json.status["정산완료"] ? json.status["정산완료"].total:0;
$scope.status_total8 = json.status["수집완료"] ? json.status["수집완료"].total:0;
$scope.$apply();
return json.results;
}
},
"select": true,
"columns": [
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" },
{ "data": "number" }
]
};
$scope.open_detail = function (type,number) {
var data = {};
data.type = type;
data.number = number;
var resolve = {
data : data
};
var modal = commonSVC.openModal("lg", resolve, 'OrderShipmentDetailOrderCtrl', 'views/order/shipment/detail_order.html');
modal.closed.then(function(){
$scope.grid.dtInstance.reloadData(function(json){ }, true);
});
};
答案 0 :(得分:1)
我找到理由。 不要使用fnRowCallback选项。 必须使用fncreatedrow