A small fix to disable Edit button if multiple rows have been selected.
Added by Gabrio gabs 225 days ago
Heres a small code addition that disables the edit button in the grid when you have more than one row selected.
In any list.html.erb file, change this:
@
selections.on('selectionchange', function(){
var n = selections.getSelected();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
btns.edit.enable();
return;
}
});
@
... into this:
@
selections.on('selectionchange', function(){
var n = selections.getSelected();
var c = selections.getCount();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
if(c > 1) {
btns.edit.disable();
} else {
btns.edit.enable();
}
return;
}
});
@
Replies
RE: A small fix to disable Edit button if multiple rows have been selected. - Added by Gabrio gabs 225 days ago
Strange, code block got messed up.. I try again:
change:
@selections.on('selectionchange', function(){
var n = selections.getSelected();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
btns.edit.enable();
return;
}
});@
into:
@selections.on('selectionchange', function(){
var n = selections.getSelected();
var c = selections.getCount();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
if(c > 1) {
btns.edit.disable();
} else {
btns.edit.enable();
}
return;
}
});@RE: A small fix to disable Edit button if multiple rows have been selected. - Added by Gabrio gabs 225 days ago
oh well.. here it is again..
change this:
----------------
selections.on('selectionchange', function(){
var n = selections.getSelected();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
btns.edit.enable();
return;
}
});
----------------
into this:
----------------
selections.on('selectionchange', function(){
var n = selections.getSelected();
var c = selections.getCount();
var btns = grid.getTopToolbar().items.map;
if(!n){
btns.remove.disable();
btns.edit.disable();
return;
} else {
btns.remove.enable();
if(c > 1) {
btns.edit.disable();
} else {
btns.edit.enable();
}
return;
}
});
----------------RE: A small fix to disable Edit button if multiple rows have been selected. - Added by Gabrio gabs 225 days ago
I give up..
RE: A small fix to disable Edit button if multiple rows have been selected. - Added by Gabrio gabs 225 days ago
sorry about all the spam, please delete the past three posts. Heres a file with the code
fix_edit_button.txt (72 Bytes)
