Calx comes with several API that can be invoked using this syntax $('selector').calx('method'),
here is list of available method that can be accessed by jQuery Calx:

  • calculate

    $('selector').calx('calculate')

    This method is used to trigger calculation process on the sheet related to the selected element,
    which is useful when you configure jQuery Calx with autoCalculate : false or working
    with large sheet where the calculation process take some times to finish and need to be triggerred
    manually.

  • destroy

    $('selector').calx('destroy')

    This method is used to destroy sheet object related to the selected element, any formula referenced
    to the cells inside this sheet will become invalid, and may result in wrong calculation.

  • evaluate

    $('selector').calx('evaluate', formula)

    This method is used to evaluate formula against the current selected sheet, all cell addresses and
    variables are referenced to the current sheet.

    You can do something like :

    $('selector').calx('evaluate', 'SUM(A1:A5)')

    and jQuery Calx will return the result of the formula.

  • setValue

    $('selector').calx('setValue', cellAddress, cellValue)

    This method is used to set the value into specific cell, it will recalculate the sheet if the autoCalculate is enabled.

    $('selector').calx('setValue', 'A1', 100)

  • getCell

    $('selector').calx('getCell', cellAddress)

    This method is used to retrieve specified cell object of the selected sheet.
    Please refer to Cell API for detailed documentation about cell object.

  • getSheet

    $('selector').calx('getSheet')

    This method is used to retreive sheet object related to the selected element.
    Please refer to Sheet API for detailed documentation about sheet object.

  • getUtility

    $('selector').calx('getUtility')

    This method is used to retrieve utility object when you need some help with the cell or cell range.

  • refresh

    $('selector').calx('refresh')

    This method is used to force jQuery Calx to rebuild the sheet of the selected element.
    It will destroy the cell registry and rebuild it from scratch.

  • registerFunction

    $('selector').calx('registerFunction', FUNCTION_NAME, function_definition

    [, override])

    This method is used to register new function and can be used in data-formula attribute.
    The parameters is described as below:

    • FUNCTION_NAME
      the function name such as SUM, AVG, etc, must be uppercase letter
    • function_definition
      the function definition define how the function should behave function(){ /** bla bla bla **/ },
      jQuery Calx will pass the sheet object as the context, so you can access all the sheet API via
      this keyword.
    • override
      the optional override flag, could be true or false to indicate if new function should override the
      original one or not. If true, the built in function will be overrided, default value is false.
    And after the function is registered, you can simply write it in the data-formula attribute:
    <span data-formula="CUSTOM(A1,A2,100,C1:D5)"></span>
  • registerVariable

    $('selector').calx('registerVariable', var_name [, var_value])

    This method is used to register variables to the calx, and are available to all sheet. The variable name
    should be all lowercase and underscore character ([a-z_]) and the value could be anything as far as the function
    can handle it.

    Or you can define multiple variable at one time using javascript object

    After variable is registered, you can reference it in data-formula attribute like
    data-formula="CONCAT('I was born in ', the_year_i_was_born)"

    Please note that there are predefined variables: true, false, and null disregard of the character is lower
    case or upper case, or mix of both, which mean true, TRUE, tRue are all the same.

  • update

    $('selector').calx('update')

    This method is used to update cell registry against any change in the element related to the sheet,
    update is similar to refresh, but instead of rebuild the cell registry from
    the scratch, it only add or delete cell that has been added or removed from the sheet’s element.

    This is useful when you are working with dynamic form where form elements are added or removed on the fly.

  • reset

    $('selector').calx('reset')

    This method is used to reset the form inside the sheet element to its original state.