writeback

This function allows you to setup a writeback for a given, visible cell on the report.

Syntax

writeback (cell, value)

Arguments

cell

(Required)

The report cell to setup the writeback on. The format of this argument can either be:

  • A string of the cell id, e.g. “R1C1”
  • A jQuery object of the cell, e.g. $(“#R1C1”)

value

(Required)

The value to writeback

Return

This function does not return any value.

Examples

The following code will setup a click event handler on all hyperlinks on the report and then, if the text of the hyperlink is “Copy”, it will copy the value from the cell to the left of the hyperlink into the cell on the right of the hyperlink (see screenshot below).

report.api.bind('postrender',function() {

    // Attach a click handler to all hyperlinks on this report
    report.root.find('a').bind('click', function() {
 
        // Only perform the action if the hyperlink is "Copy"
        if ($(this).text() === 'Copy') {
 
            // Get the Left cell to copy from
            var copyFromCell = $(this).parent().prev();
            var copyToCell = $(this).parent().next();
 
            report.api.writeback(copyToCell, copyFromCell.text());
        }
    })
});