Banana.Document.Table

This documentation is outdated

The most complete and up-to-date documentation is the one of Banana Accounting Plus: Try it now

In this article

Banana.Document.Table is the interface of a table.

Properties

name

Return the xml name of the table.

var table = Banana.document.table("Accounts");
var tName = table.name;

columnNames

Return the xml names of the table's columns as an array.

var table = Banana.document.table("Accounts");
var tColumnNames = table.columnNames;

listName

Return the xml name of the list that this table object reference to. The default list is the 'Data' list.
Since Banana 8.0.5

var table = Banana.document.table("Accounts");
var tListName = table.listName;

listNames

Return the xml names of the available lists as an array. The default list is the 'Data' list.
Since Banana 8.0.5

var table = Banana.document.table("Accounts");
var tListNames = table.listNames;

rowCount

Return the number of rows in the table.

var table = Banana.document.table("Accounts");
var tRowCount = table.rowCount;

rows

Return the rows of the table as an array of Row objects.

var table = Banana.document.table("Accounts");
var tRows = table.rows;

 

Methods

addMessage(msg, rowNr [, columnName] [, idMsg])

Add the message msg to the queue of the document. The message is showed in the pane "Messages", and in a dialog if the application option "Show Messages" is turned on.

If idMsg is not empty, the help button calls an url with message's id (idMsg) as parameter.

If rowNr is different than "-1" the message is connected to the row rowNr. if columnName is not empty, the message is connected to the column columnName. With a double click over message in the message pane, the cursor jump to the corresponding table, rowNr and columnName.

See also: Application.AddMessageRow.AddMessage, Document.AddMessage.

var table = Banana.document.table("Accounts");
table.addMessage("Message string", 3, "description");

extractRows( function(rowObj, rowNr, table), tableTitle)

Extract the rows that passed the test defined by function and show them in the table "Selections". The title of the table is set to tableTitle.

findRows( function(rowObj, rowNr, table))

Return an array of Row objects that pass the test defined in function.

findRowByValue(columnName, value)

Return the first row as Row object that contains the value in the the column columnName. Or undefined if any row is found.

var cashAccountRow = Banana.document.table('Accounts').findRowByValue('Account','1000');
if (!cashAccountRow)
   //Row not found

list(xmlListName)

Return a new table object with the rows of the list xmlListName, or undefined if the list xmlListName doesn't exist.

var recurringTransactions = Banana.document.table('Transactions').list('Examples');
var archivedProducts = Banana.document.table('Products').list('Archive');

Since Banana 8.0.5

row(rowNr)

Return the Row at index rownr as Row Object, or undefined if rowNr si outside the valid range.

var table = Banana.document.table("Accounts");
var row = table.row(3);

toJSON([columnNames])

Return the table as JSON string. If the parameter columnNames is defined, only the columns in the array are included in the file.

var table = Banana.document.table("Accounts");
var json = table.toJSON();

toHtml([columnNames, formatValues])

Return the table as Html file. If the parameter columnNames is defined, only the columns in the array are included in the file. If formatValues is set to true, the values are converted to the locale format.

Example:

//Show the whole row content of the table Accounts
Banana.Ui.showText(Banana.document.table('Accounts').toHtml());

//Show some columns and format dates, amounts, ... as displayed in the program
Banana.Ui.showText(
   Banana.document.table('Accounts').toHtml(['Account','Group','Description','Balance'],true)
);

toTsv([columnNames])

Return the table as Tsv file (Tab separated values). If the parameter columnNames is defined, only the columns in the array are included in the file.

var table = Banana.document.table("Accounts");
var tsv = table.toTsv();

value(rowNr, columnName)

Return the value in row rowNr and column columnName as string. Or undefined if the row or column are not found.

var table = Banana.document.table("Accounts");
var account = table.value(3,'Account'); 
var description = table.value(3,'Description');

 

 

Share this article: Twitter | Facebook | LinkedIn | Email