I'd like to mimic a particular behavior of spreadsheets with SlickGrid. The user:
- clicks on a cell to activate it
- enters
=sum(
, or whatever formula, - the original cell address is saved
- the user selects the cell range (I assume that the original cell closes the editor)
- focus is returned to the original cell with the new cell range appended. i.e. =sum(r1c1,r2c2).
What's throwing me off is the need to change focus.
var cell_with_formula = null;
grid = new Grid($("#myGrid"), data, columns, options);
// save original cell address, but there is no onBlur event
grid.onBlur = function(args){
cell_with_formula = args; // save address
};
grid.onCellRangeSelected = function(){
if(cell_with_formula){
// check if cell_with_formula has `=` at begining
// if so, append selected range
cell_with_formula = null;
}
};
Thanks in advance!
This is not possible in SlickGrid 1.4.x, but is going to be supported in the version 2.0 that is currently still under active development. The alpha is hosted in a separate branch on GitHub - https://github.com/mleibman/SlickGrid/tree/v2.0a, and I just checked in preliminary code that supports this with an example. Please see https://github.com/mleibman/SlickGrid/commit/17b1bb8f3c43022ee6aec89dcab185cd368b8785.
Here's a basic formula editor implementation: