0
我需要發送刪除行爲中沒有標記爲關鍵字的字段。正如在我的情況下,我想要使用多個字段刪除一行。我們如何發送刪除行動中不是關鍵字
我需要發送刪除行爲中沒有標記爲關鍵字的字段。正如在我的情況下,我想要使用多個字段刪除一行。我們如何發送刪除行動中不是關鍵字
我找到了答案。我們需要在jtable的字段部分添加此代碼
customDelete: {
title: '',
width: '0.3%',
display: function(data) {
var $but = $('<button title="delete" class="jtable-command-button jtable-delete-command-button" >delete</button>');
$but.click(function(){
var $dfd = $.Deferred();
if(data.record.configType == 'global')
{
alert('Global Type Configuration are not allowed for deletion.')
return false;
}
if (confirm('Are you sure you want to delete this?')) {
$.ajax({
url: '/admin/configuration/delete',
type: 'POST',
dataType: 'json',
data: data.record,
success: function (data) {
$dfd.resolve(data);
$('#Container').jtable('load') ;
},
error: function() {
$dfd.reject();
}
});
}
});
return $but;
}
},
}
您可以編寫自定義函數來刪除,而不僅僅是URL。當doin添加你想發送數據的字段時,通過ajax發送。請參閱下面的代碼以及文檔http://www.jtable.org/demo/FunctionsAsActions。
$('#Container').jtable({
//...other code
actions: {
deleteAction: function (postData) {
console.log("deleting from custom function...");
//Attach your values to postData...
//make sure you collect it in controller/code
postData.customData = $('#myinput').val();
return $.Deferred(function ($dfd) {
$.ajax({
url: '/Demo/DeleteStudent',
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
},
error: function() {
$dfd.reject();
}
});
});
},
//...other actions
},
});
//Load student list from server
$('#Container').jtable('load');
});
您能分享您正在使用的代碼以及您遇到的具體問題嗎? –