1
鑑於下面,當我點擊我的命令按鈕時,它也會觸發selected.rs。觸發行選擇的命令按鈕
理想情況下,我想,以避免行選擇,但具有相同的功能,如果在第一列的值被點擊
$(document).ready(function() {
var grid = $("#my_grid").bootgrid({
ajax: true,
rowSelect: true,
selection: true,
multiSelect: false,
keepSelection: true,
post: function() {
return {
id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
};
},
url: "response.php",
formatters: {
"commands": function(column, row) {
if (row.active == "t") {
var buttonToggle = "<button type=\"button\" class=\"btn btn-xs btn-default command-disable\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-remove-circle\"></span> Disable Zone</button>";
} else {
var buttonToggle = "<button type=\"button\" class=\"btn btn-xs btn-default command-enable\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-ok-circle\"></span> Enable Zone</button>";
}
return "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-trash\"></span> Delete</button> " + buttonToggle;
},
"status": function(column, row) {
if (row.active == "t") {
return "Active";
} else {
return "Inactive";
}
},
"link": function(column, row) {
return "<a href=\"#\">Edit: " + row.id + "</a>";
},
},
templates: {
header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\"><div class=\"col-sm-12 actionBar\"><div class=\"{{css.search}} pull-left\"></div><div class=\"{{css.actions}}\"></div></div></div></div>"
},
labels: {
infos: "Showing {{ctx.start}} to {{ctx.end}} of {{ctx.total}} zones"
}
}).on("loaded.rs.jquery.bootgrid", function() {
grid.find(".command-delete").on("click", function(e) {
var conf = confirm('Delete Zone ID: ' + $(this).data("row-id") + ' ?');
if(conf) {
$.post('response.php', { id: $(this).data("row-id"), action:'delete'}
, function(){
$("#my_grid").bootgrid('reload');
});
} else {
alert('Zone ID: ' + $(this).data("row-id") + ' Not Removed');
}
}).end();
grid.find(".command-disable").on("click", function(e) {
var conf = confirm('Disable Zone ID: ' + $(this).data("row-id") + ' ?');
if(conf) {
$.post('response.php', { id: $(this).data("row-id"), action:'disable'}
, function(){
$("#my_grid").bootgrid('reload');
});
} else {
alert('Zone ID: ' + $(this).data("row-id") + ' Not Disabled');
}
}).end();
grid.find(".command-enable").on("click", function(e) {
var conf = confirm('Enable Zone ID: ' + $(this).data("row-id") + ' ?');
if(conf) {
$.post('response.php', { id: $(this).data("row-id"), action:'enable'}
, function(){
$("#my_grid").bootgrid('reload');
});
} else {
alert('Zone ID: ' + $(this).data("row-id") + ' Not Enabled');
}
}).end();
}).on("selected.rs.jquery.bootgrid", function(e, rows) {
alert("Select: " + rows[0].id);
});