jspreadsheet / ce

Jspreadsheet is a lightweight vanilla javascript plugin to create amazing web-based interactive tables and spreadsheets compatible with other spreadsheet software.
https://bossanova.uk/jspreadsheet/v4
MIT License
6.7k stars 820 forks source link

Custom toolbars Font size display the last selected font size text for all cells #1241

Open cgt-training2 opened 3 years ago

cgt-training2 commented 3 years ago

Check the example given on this link of JEXCEL official site: https://bossanova.uk/jexcel/v4/examples/spreadsheet-toolbars in the example change font size of cell A1 to 14px then click on cell A2(having font size of 9 px) the drop down shows 14px. Second issue is that it doesn't allow cell A2 to select 14px on the go but if i select 15px or any other value then if i select 14px cell A2 changed to 14px.

Please help and provide solution for this issue.

GBonnaire commented 3 years ago

For fix that, you should update all item on toolbar. Currently on Jexcel CE/Pro toolbar is not update by cell selected.

Try this :

onselection = function(el, x1, y1, x2, y2) {
       var obj = el.jexcel;
      // update toolbar items available in obj.toolbar
      // For example
       var selectFontSize = obj.toolbar.querySelector("[data-k=font-size]");
       selectFontSize.value = obj.records[y1][x1].style.FontSize;
   }
},

Now you shloud make for all items of toolbar where you want update when selection

pphod commented 3 years ago

I will add that to the wish list for future releases.

GBonnaire commented 3 years ago

@paulhodel maybe add a fonction on item toolbar for update like « onupdate(DOMElement ItemToolbar, el) ? And when onselection on spreadsheet, call onupdate of each Item toolbar ?

cgt-training2 commented 3 years ago

@Guillaume-Bo , Hello hope you're doing well.I applied suggested solution and it's working. thank you very much.