...
You can also create a result set of type JavaScriptResultSet which implements IPentahoResultSet and can be used by components that accept a IPentahoResultSet like the reporting component.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
getColumnCount() // Number of columns getRowCount() // Number of rows getValueAt( row, col ) // Returns the value os a cell, row and column are zero based setColumnHeaders( array ) // array size should match the number of columns setColumnHeaders( array1, array2 ) // array1 for col headers, array2 for column types addRow( array ) // array is a data row to add to the end of the result set getMetaData() // Returns a IPentahoMetaData object // Example: Create a result set var results = new JavaScriptResultSet(); results.setColumnHeaders( 'DIAL_DATA', 'DIAL_MIN', 'DIAL_MAX' ); results.addRow( new Array(57.0, 0.0, 100.0) ); // Example: Create a result and access it's data var results = new JavaScriptResultSet(); results.setColumnHeaders( 'REGION' ); results.addRow( new Array( 'Eastern' ) ); results.addRow( new Array( 'Western' ) ); results.addRow( new Array( 'Southern' ) ); firstrow = results.getValueAt(0,0); // returns '[Eastern]' lastrow = results.getValueAt(results.getRowCount()-1,0); // returns '[Southern]' columns = results.getColumnCount(); // returns 1 rows = results.getRowCount(); // returns 3 // Other useful methods var meta = result_set.getMetaData(); // Returns an IPentahoMetaData object var colCount = meta.getColumnCount(); var colHeaders = meta.getColumnHeaders(); //getColumnHeaders() returns object[][] var i = 0; for ( i = 0 ; i < colCount ; i++ ){ colName=colHeaders[0][i]; // use colName for something } |