bootgrid通过插入command按钮可以实现对数据行的编辑功能,为了更好地做好前台,我使用了confirmation的插件做删除确认,但在实际使用中发现问题,目前已经解决grid reload后confirmation的页面元素全部初始化的问题。
注意红色部分
grid=$("#grid").bootgrid({
ajax:true,
ajaxSettings: {
method: "GET",
cache: false
},
selection:true,
pagination: 3,
rowCount:[30,20,10,-1],
selection:true,
rowSelect:true,
labels: {
infos: '{{ctx.start}} 至 {{ctx.end}} | 总数 {{ctx.total}}',
search:'搜索档案名',
noResults: "您没有权限、登录超时或没有数据!"
},
url:sy.contextPath + '/base/hyfile!grid.sy?QUERY_t%23syuserByCreateuserid.id_S_EQ='+'<%=sessionInfo.getUser().getId()%>',
//url:sy.contextPath + '/test.json',
formatters: {
"classname":function(column, row){
return row.fileproject.fileclass.name;
},
"projectname":function(column, row){
return row.fileproject.name;
},
"timename":function(column, row){
return row.filetime.name;
},
"timekeepyear":function(column, row){
return row.filetime.keepyear;
},
"commands": function(column, row){
return "<button type=\"button\" class=\"btn btn-xs btn-warning command-edit\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-pencil\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-toggle=\"confirmation\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-trash-o\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-success command-next\" data-toggle=\"confirmation\" data-row-flow=\"" + row.flow + "\" data-row-id=\"" + row.id + "\"><span class=\"fa fa-angle-right\"></span></button>";
}
}
}).on("loaded.rs.jquery.bootgrid", function()
{
$("#grid-footer").css("position","fixed");
$("#grid-footer").css("bottom","-10px");
$("#grid-footer").css("min-width","900px");
/* Executes after data is loaded and rendered */
grid.find(".command-edit").on("click", function(e)
{
edit($(this).data("row-id"));
}).end().find(".command-delete").on("click", function(e)
{
//del($(this).data("row-id"));
$('.command-delete').confirmation({
title:'确认删除?',
btnOkClass:'btn-danger',
btnCancelClass:'btn-primary',
btnOkLabel:'<i class="glyphicon glyphicon-ok"></i> 是',
btnCancelLabel:'<i class="glyphicon glyphicon-remove"></i> 否',
onConfirm:function(){
del( $('.command-delete').data("row-id"));
$('.command-delete').confirmation('toggle');
},
<span style="color:#ff0000;"><strong>container: 'table',</strong></span>
singleton:true,
popout:true
});
}).end().find(".command-next").on("click", function(e)
{
//del($(this).data("row-id"));
$('.command-next').confirmation({
title:'确认发送下一步?',
btnOkClass:'btn-danger',
btnCancelClass:'btn-primary',
btnOkLabel:'<i class="glyphicon glyphicon-ok"></i> 是',
btnCancelLabel:'<i class="glyphicon glyphicon-remove"></i> 否',
onConfirm:function(){
//del($(this).data("row-id"));
sendToNext( $('.command-next').data("row-id"),$('.command-next').data("row-flow"));
$('.command-next').confirmation('toggle');
},
placement:'left',
<span style="color:#ff0000;"><strong>container: 'table',</strong></span>
singleton:true,
popout:true
});
});
});