-2
我已經在我的項目中實施了引導程序gtreetable。一切工作正常,但我有刪除節點的問題。我已經安裝了bootstrap-gtreetable.js和bootstrap-gtreetable.min.js。創建和更新工作文件,但只有刪除不起作用,它也不會在控制檯中引發任何錯誤。我的代碼如下。 我初始化gtreetable jQuery代碼如下:無法刪除引導程序中的節點gtreetable
$(document).ready(function() {
jQuery('#gtreetable').gtreetable({
'source': function (id) {
return {
type: 'GET',
url: 'GetCategories',
data: { 'id': id },
dataType: 'json',
error: function (XMLHttpRequest) {
alert(XMLHttpRequest.status + ': ' + XMLHttpRequest.responseText);
}
}
},
"onSave": function (oNode) {
if(oNode.getName().length>0)
return {
type: 'POST',
url: !oNode.isSaved() ? 'CreateCategory' : '/Category/UpdateCategory/?id=' + oNode.getId(),
data: {
parent: oNode.getParent(),
name: oNode.getName(),
position: oNode.getInsertPosition(),
related: oNode.getRelatedNodeId()
},
dataType: 'json',
error: function (XMLHttpRequest) {
alert(XMLHttpRequest.status + ': ' + XMLHttpRequest.responseText);
}
};
window.location.refresh();
},
"onDelete": function (oNode) {
return {
type: 'POST',
url: '/Category/DeleteCategory/?id=' + oNode.getId(),
dataType: 'json',
error: function(XMLHttpRequest) {
alert(XMLHttpRequest.status+': '+XMLHttpRequest.responseText);
}
};
},
"selectLimit": 0,
"showExpandIconOnEmpty": false,
"language": "en-US",
"manyroots": false,
"draggable": false,
"inputWidth": "300px",
'types': {
'folder': 'glyphicon glyphicon-tasks',
'default': 'glyphicon glyphicon-dashboard'
},
"defaultActions": [
{
name: 'Create Category',
event: function (oNode, oManager) {
oNode.add('lastChild', 'default');
}
},
{
divider: true
},
{
name: 'Update',
event: function (oNode, oManager) {
oNode.makeEditable();
}
},
{
divider: true
},
{
name: 'Delete',
event: function (oNode,oManager) {
oNode.onDelete;
}
},
{
divider: true
}
]
});
});
我的服務器端代碼DELET節點如下:
[HttpPost]
public virtual JsonResult DeleteCategory(int id)
{
var category = _categoryService.DeleteCategory(id);
return Json(category, JsonRequestBehavior.AllowGet);
}
請將您的代碼複製並粘貼到問題中。代碼的圖像是沒用的 –