Custom cell type break the formula bar

Posted by: davide.vago on 31 August 2019, 12:33 am EST

  • Posted 31 August 2019, 12:33 am EST

    Good morning/afternoon

    Following up this ticket: https://www.grapecity.com/forums/spread-sheets/set-up-metadata-to-cell

    Creating a custom cell type breaks the reference of the formula bar, the standard formula bar shows [object Object] as value rather than the cell text.

    Looking forward to hearing from you
  • Replied 1 September 2019, 8:57 pm EST

    Hi,

    For supporting FormulaTextBox, you may modify the custom cell type to accept an instance of workbook and use it to fetch values when worksheet context is not available i.e in case of FormulaTextBox. Also, we need to override the toString() method of the custom object value to display it correctly in the FormulaTextBox. Please refer to the following updated sample and let us know if you face any issues:
    https://codesandbox.io/s/spread-js-starter-rdiv3

    Regards
  • Replied 1 September 2019, 11:10 pm EST

    Good morning/evening Sharad,

    The snippet does work correctly, however there are a couple of issues,
    try within your code sample to:

    1) modify the value of a cell using a formula e.g. set to Bob within the isAdult column something like "=IF(B2)".

    2) after the first step try to update the text to "=IF(B1)".

    The formulas are not being applied, the cell prints out the text instead of evaluating the formula and furthermore the update of the same cell doesn't work when a formula text is applied.

    In general the formulas are not being evaluated correctly.
    Let's say we add a new row within the spreadsheet which doesn't contain custom cell type and has a formula applied that refers to custom cell types the output doesn't show
  • Replied 2 September 2019, 6:30 pm EST

    Hi Davide,

    We have escalated this case to the dev team. We will update soon regarding the same. The internal tracking Id for the case is SJS-1578.

    Regards
  • Replied 3 September 2019, 7:53 pm EST

    Thanks for the support,
    Would you know an ETA of a solution for this? It's quite crucial for the project I'm working on.

    Thanks in advance

  • Marked as Answer

    Replied 4 September 2019, 5:44 pm EST

    Hi Davide,

    Devs have suggested using the cell tags. Cell tags are used to attach additional information on a cell. Cell tags would support formulas out of the box, additionally, other features like filtering, conditional formatting, data validation... etc would also be supported. The only downside is you would have to loop through all rows and set the tag info for the cell.
    Please refer to the following sample demonstrating the use of cell tags and let us know if you face any further issues:
    https://codesandbox.io/s/spread-js-starter-2ej1h
  • Replied 4 September 2019, 7:28 pm EST

    Devs also suggested a better workaround by defining the value function for a column. Please refer to the following code sample which demonstrates the same:
    https://codesandbox.io/s/spread-js-starter-vquim
  • Replied 5 September 2019, 12:22 am EST

    Thanks for getting back to me Sharad,

    I've been trying to implement the bindColumns method (second link) as it seems more clean but I got stuck on formulas, in fact, some of my columns contains at the very end cells with some formula (e.g. =AVERAGE(cell1:cellN))

    The output of the cell is white even if the value when the user clicks on the cell is showing correctly on the formula bar
  • Replied 5 September 2019, 5:07 pm EST

    We are sorry but we are unable to replicate the issue at our end, In our tests formulas seems to be evaluated correctly, could you please have a look at the following sample and let us know if we are missing something in order to replicate the issue:
    https://codesandbox.io/s/spread-js-starter-ef99h
  • Replied 5 September 2019, 11:32 pm EST

    I've tried to understand better the difference between the sample code and my current code and there must be something which is not related to the formula itself,
    in fact, it doesn't display the cell value (paint) on edit when a cell has a null value or there is a row in the middle of the data set which is empty even if the new value gets applied and the formula bar shows the new value.

    I've applied the first solution which makes me feel bad but it does the job (setting the dataset and looping through all the values to reset the value and add a tag)
  • Replied 8 September 2019, 6:30 pm EST

    If info object itself is also supposed to be null in some case then we may update our value function to handle null value cases too. Please refer to the following code snippet and the sample demonstrating the same:
    var colInfos = [
    { name: "name" },
    { name: "isAdult" },
    { name: "country" },
    { name: "website" },
    {
    name: "info",
    value: function(item, value) {
    if (arguments.length > 1) {
    item["info"].value = value;
    } else {
    return item["info"] && item["info"].value;
    }
    }
    }
    ];

    https://codesandbox.io/s/spread-js-starter-cgs56

    If the issue persists, could you please update the above sample to demonstrates the issue so that we could further investigate it.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels