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

how to update cell with proogram with pro version? #1148

Open benci042 opened 3 years ago

benci042 commented 3 years ago

Hi Paul I'm using pro version, special cell can be using init data to build jexcel. like this https://jexcel.net/v5/cases/payment-calculator

and now i has new issule ,how to change it by programmatically? i can using getcells return it . and got error msg "cellName is not defined" when i using setcell .like this table.setCells('D1',object) . thanks.

pphod commented 3 years ago

would you like to change the value?

table.setValue('D1', 'newvalue')

benci042 commented 3 years ago

Thanks for your response , I mean how to change cell type by programmatically. for example ,i need to change "D1" with dropdown with existing table.

pphod commented 3 years ago

Sorry, we are going to include a fix for the method. Meanwhile, this would be the best way to change the object properties.

Changing for type text: table.options.cells['D1'].type = 'text';

Changing for type dropdown: table.options.cells['D1'].type = 'dropdown'; table.options.cells['D1'].source = ['Apples','Pears']; // add here the options

Etc.

benci042 commented 3 years ago

Noted with thanks.

benci042 commented 3 years ago

sorry to interrupt you , when i try put table.options.cells['D1'].type ='text'; I got error message, can't read prperty 'type' of undefined .

pphod commented 3 years ago

If you are setting a new one you should define the whole property: table.options.cells['D1'] = { type:'text' } table.options.cells['D1'] = { type:'dropdown', source:['Apple','Pears'] };

benci042 commented 3 years ago

big thanks.

benci042 commented 3 years ago

image image it's working now . and has little problem. The cell not has dropdown symbol . FYI...

pphod commented 3 years ago

We will make sure to include a method to do that automatically, for now: table.records[0][0].element.classList.add('jexcel_dropdown'); // 0,0 means A1 where y,x table.records[0][3].element.classList.add('jexcel_dropdown'); // 0,3 means D1 where y,x table.records[1][4].element.classList.add('jexcel_dropdown'); // 1,4 means E2 where y,x

Regards,