When I put code in the onRender(e) event, the OnRender event keeps firing causing stack overflow errors.
What I've succeeded in doing is:
loading my model (Columns A-N)
What I'd like to do after the model has loaded is:
1. Disable columns A:B
2. Add formulas in Columns (O-Q)
How do I do this?
3 Answers, 1 is accepted
I apologize for the delayed response.
Disabling cells can be achieved by retrieving the specified range, which we would like to disable and then using the Spreadsheet Range's enable() method. This is demonstrated in the following Spreadsheet demo:
For applying a formula to a cell, the Spreadsheet Range's formula() method can be used. Check out the following Dojo example, where you can see the method in action:
I hope this helps. Should you have any additional questions, please let me know.
Another question in the same vein is how to add formulas to a model bound spreadsheet and then add headings to them. When I do this via code it corrupts my model (please see attached example)
I am attaching and ASP.NET MVC solution, where a similar scenario to the one described is demonstrated (Disabling column cells and adding formula after the initialization of the Spreadsheet).
Indeed you are correct that the render event is not suitable to be used in this case. In order to set disabled cells and add custom formulas after the Spreadsheet is completely rendered and the data is loaded, the DataSource's requestEnd event can be used:
You will notice that the entire coolumn cells that contain value can be disabled by using the following approach:
Concerning the model changes, it is expected that when changing the model data (e.g field title), that the dirty flag of the model will be set to true. Can you elaborate a bit more on what are your concerns regarding this behavior in the specific use case?