Hi,
version 6.2.7
I would like to try use contextMenu like showcase, this work fine on the fisrt load, but when I update data on the sheet, contextMenu is be lost !
How can I create it and always stay ? It should be great to don't have to recreated at each refresh ?
Thanks for your help
Sheet contextMenu disapear after sheet update
I think there is 1 of 2 ways to solve it.
1. Put in in a JS function and call it after your Ajax Update like...
2. Instead of using $hot.updateSettings doing it in the Sheet Extender funciton. The Extender should get called on every update of the sheet when it re-initializes.
1. Put in in a JS function and call it after your Ajax Update like...
Code: Select all
<p:ajax update="mySheet" oncomplete="addContextMenuJs();" />
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
Now that I think about it you may have to use Solution #1 because in #2 the sheet doesn't exist yet the Extender is before the sheet is created so there is no way to get at the $hot value.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
Thanks Melloware, it's exact, on the extender I can only use standard declaration like :
but not your.
Than I've implemented the 1 solution.
For your information, I saw an error with contextMenu if the sheet is empty.
Now, I look the better way for insert (after or before) a "Template" line with default value by backing bean to integrate it on the same time into the database table .... Any experience ?
Code: Select all
this.cfg.contextMenu = ['row_above', 'row_below', '---------', 'undo', 'redo'];
Than I've implemented the 1 solution.
For your information, I saw an error with contextMenu if the sheet is empty.
Now, I look the better way for insert (after or before) a "Template" line with default value by backing bean to integrate it on the same time into the database table .... Any experience ?
Yeah the context menu you might have to get smarter with the JS code. I grabbed their example almost exactly from the HandsonTable docs...
https://docs.handsontable.com/5.0.0/dem ... -menu.html
https://docs.handsontable.com/5.0.0/dem ... -menu.html
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
Hi, with the solution to add contxet menu after each change, I found a handsontable issue => event hooks calling more time than once !
Similar problem of https://github.com/handsontable/handson ... ssues/3343
Than I look how is it posssible to re add context menu and also hook.
Here my patch exemple solution for remove row :
Hope this can help someone !
Similar problem of https://github.com/handsontable/handson ... ssues/3343
Than I look how is it posssible to re add context menu and also hook.
Here my patch exemple solution for remove row :
Code: Select all
$(document).ready(function () {
addContextMenu();
});
function addContextMenu() {
var $hot = PF('listSheet').ht;
$hot.removeHook('afterRemoveRow', cbRemoveRow); // this is very important !
$hot.updateSettings({
contextMenu: {
items: {
"remove_row": {
name: 'Delete line(s)',
disabled: function () {
// if first row, disable this option
try {
return $hot.getSelected()[0] === 0;
} catch (error) {
return true;
}
}
}
}
});
$hot.addHook('afterRemoveRow', cbRemoveRow);
}
;
function cbRemoveRow (index, amount){
deleteRows([{name: 'index', value: index}, {name: 'amount', value: amount}]);
};
Excellent!
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1
-
- Information
-
Who is online
Users browsing this forum: No registered users and 24 guests