We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Getting value of cell w/in onCellSave(args)

I have code where I use ranges to calculate min/median/max values in another table and also a total in another table w/in the spreadsheet:
i.e. this.XLEdit.updateCellValue({ rowIndex: rowIndexNum, colIndex: colIndexNum }, "=MIN(" + rangeToCalc + ")");
Above & similar lines actually trigger onCellSave(args) so I was passing args.value to local storage if it is an integer since all the calcs. aside from what I enter that run onCellSave(args) end up looking like "E6:F6" for example.
I then go to read the value in that cell like: var value = this.getAlphaRange(rowIndexNum, colIndexNum).value; but it keeps returning as undefined so I'm guessing I can't grab that value while still in onCellSave(args) until after the page loads? Is this accurate? If so do you have any suggestions for how to get those values of cells after inputting.

The scenario is we set min, max, median and then if the inputted number is > or < the value in a specific cell (which gets updated on each entry so it has to be in onCellSave(args) then the cell that was just entered will update it's color based on being less than, between two values, or greater than. Like:                     xlFormat.format({ "style": { "background-color": "#99c199", "text-align": "center" } }, this.getAlphaRange(args.rowIndex, args.colIndex));









1 Reply

SK Shanmugaraja K Syncfusion Team September 14, 2017 05:23 AM UTC

Hi Jacob, 
 
Thanks for using Syncfusion products, 
 
We have checked your requirement, and we suggest you to pass the range to getRangeData method to get the corresponding values. Please refer the below code example, 
 
[JS] 
 
 
        $(function () { 
            $("#Spreadsheet").ejSpreadsheet({ 
                cellSave: "onCellSave" 
            }); 
        }); 
 
        function onCellSave(args) { 
            var val = args.value, rng; // e.g. val is =MIN(B2:B6) 
            if (val && val.startsWith("=")) { 
                rng = val.slice(val.indexOf("(") + 1, val.indexOf(")")); // rng is B2:B6. 
                data = this.getRangeData({ range: rng, property: "value" }); // you can get the data here. 
                console.log(data); 
            } 
        }; 
 
 
We have demonstrated the sample in JSPlayground, please refer the below sample link and documentation link, 
 
 
Regards, 
Shanmugaraja K 


Loader.
Live Chat Icon For mobile
Up arrow icon