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 cell type for one cell only #224

Closed tejcirkulate closed 5 years ago

tejcirkulate commented 5 years ago

Hi Paul, I am looking for a way to change a particular cell's type programmatically. I've seen one issue here: https://github.com/paulhodel/jexcel/issues/65

But that works only for changing the whole column's type, not one particular cell.

I need to use this for functionality that will work like this:

  1. Right click on cell to show context menu.
  2. Select "Change Type to XYZ" in Context Menu.
  3. Activate editing for this cell. This should open a custom editor modal for the selected cell only.
tejcirkulate commented 5 years ago

Another way may be to declare all columns as a custom type cell such that each open editor action checks for some meta-data to determine whether to open a custom editor for the cell or fallback to the default text editor. I think its this one.

https://github.com/paulhodel/jexcel/blob/97ed98e2b3bc1776643e23eab21277d99118ee78/dist/js/jquery.jexcel.js#L1747

For thie to work, then I'll need a way to call into the default editor for a text type cell from my custom open editor handler. Is that possible? I am guessing that final else block may have to be moved into its own function or something so that it can be called externally.

pphod commented 5 years ago

The text type is very easy to implement outside jExcel, them you can build any behaviour you want since you know the ROW you are edition you can target different actions based on that.

A good example on how to build your custom column. From a custom column is not possible to call native editors, but as I said, the text editor is very easy to re-implement with a few lines.

https://bossanova.uk/jexcel/examples/integrating-a-third-party-plugin-into-your-spreadsheet