writeback¶
This function allows you to set up writeback for a given, visible cell on the report.
Syntax
writeback (cell, value)
Arguments¶
cell : string
(required)¶
The report cell to set up 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 : number
(required)¶
The value to writeback.
Return¶
This function does not return any value.
Examples¶
The following code will set up 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.api.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());
}
})
});