How to get value changed by custom renderer?

Tags: #<Tag:0x00007efc6564fee8>

Hi,

To my knowledge, all the data retrieval method provided by the Handsontable instance will return data values provided initially. Is there a way to get the value that is currently visible to the user which is changed by a custom renderer?

For example, I pass in a data array which is [[1, 2, 3]], a custom renderer parses the row and converts the values into a minimum of 4 d.p. before displaying to the user. Understand that a possible solution is to do the parsing before passing the data array into Handsontable, but would like to avoid that as the datasets could be huge and the initial rendering could be delayed significantly.

Hi @prakoso.santoso

If you want to get this value outside the renderer you can use the getCell method, like here https://jsfiddle.net/handsoncode/7xfLw4km/
Would that ve helpful for your use case?

Hi Aleksandra,

Thank you for the solution, it works partially for my use case as we need to account for cells that are not currently visible to the user, i.e if the user selects all the cells available and it stretches beyond their viewport while virtual scrolling is used, we won’t be able to retrieve the data required as getCell can only select the element currently being rendered. Is there a way to programmatically apply the custom render function for each of the cell through a method like getCell?

Perhaps like a combination of getSourceData and passing it into the custom renderer function using getCellRenderer and calling the function without actually doing any rendering? Not sure if that makes sense.

Thank you.

You can still use getCell approach if you want to use renderAllRows method https://jsfiddle.net/handsoncode/uoyg853v/ but if you have a lot of rows or heavy logic then it is not recommended.
Maybe then you can save your renderer as a template and reuse it afterwards to get the value. Here’s an example https://jsfiddle.net/handsoncode/1ad4oyfk/