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


    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

  • 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


    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


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

  • 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:

      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.
    $('selector').calx('registerFunction', 'CUSTOM', function(args1, args2, ... , argsN){
        //<this> keyword will be sheet object where the current formula is evaluated
        //if data-formula look like CUSTOM(A1), the value of A1 will be passed as args1
        //if data-formula look like CUSTOM(A1:B2), the value of args1 will be like
        //{A1:value, A2:value, B1:value, B2:value}
        //function should return calculated value to be rendered into the cell that invoke this function

    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.

    $().calx('registerVariable', 'the_year_i_was_born', 1988)

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

    $().calx('registerVariable', {varname: 'value', another_var: 'another value'})

    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


    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


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