2

正如标题所说,我该怎么做?,我正在使用jiri创建的这个按钮:

如何使用 SlickGrid 插件在每一行上创建一个删除按钮?

当我在函数中添加 if(confirmation(msg)) 时,它会重复我的 msg ALOT 可能是因为我在每次修改时都刷新了表。

问我是否需要更多信息,我在stackoverflow中仍然是菜鸟:P(如果有某种方式可以“杀死”该功能)

这是按钮,我正在使用(链接)我添加了 idBorrada 以检查 id 是否已被删除并且不要尝试删除它两次,这也是一个确认,但是当我触摸取消时它再次询问我。

$('.del').live('click', function(){ var me = $(this), id = me.attr('id'); //assuming you have used a dataView to create your grid //also assuming that its variable name is called 'dataView' //use the following code to get the item to be deleted from it if(idBorrada != id && confirm("¿Seguro desea eleminarlo?")){ dataView.deleteItem(id); Wicket.Ajax.ajax({"u":"${url}","c":"${gridId}","ep":{'borrar':JSON.stringify(id, null, 2)}}); //This is possible because in the formatter we have assigned the row id itself as the button id; //now assuming your grid is called 'grid' //TODO grid.invalidate(); idBorrada= id; } else{ }; });

我再次调用整个函数。希望有所帮助,抱歉语法不是我的母语

4

1 回答 1

4

跟着这些步骤,

  1. 为列对象的每一行添加一个删除链接,如下所示,
var columns = 
   { id: "Type", name: "Application Type", field: "ApplicationType", width: 100, cssClass: "cell-title", editor: Slick.Editors.Text, validator: requiredFieldValidator, sortable: true },
   { id: "delete", name: "Action", width: 40, cssClass: "cell-title", formatter: Slick.Formatters.Link }
];
  1. 在 slick.formatters.js 中添加一个链接格式化程序,如下所示,
"Formatters": {
   "PercentComplete": PercentCompleteFormatter,
   "YesNo": YesNoFormatter,
   "Link": LinkFormatter
}

function LinkFormatter(row, cell, value, columnDef, dataContext) {
   return "<a style='color:#4996D0; text-decoration:none;cursor:pointer' onclick='DeleteData(" + dataContext.Id + ", " + row + ")'>Delete</a>";
}
  1. 在javascript中添加以下删除函数
function DeleteData(id, rowId) {
   var result = confirm("Are you sure you want to permenantly delete this record!");
   if (result == true) {
       if (id) {
           $.ajax({
               type: "POST",
               url: "DeleteURL",
               data: { id: id },
               dataType: "text",
               success: function () {
               },
               error: function () {
               }
           });
       }
       dataView.deleteItem(id);
       dataView.refresh();}
}
于 2013-07-19T09:12:08.590 回答