Skip to main content

Using Data Returned by the Data Controller

Using Data Returned by the Data Controller

The page must also implement the callback function or functions referred to in the previous step. These callbacks should update the page as needed, using data obtained from the data controller object.

In each case, the data controller object is passed to the function as the argument.

The following shows a partial example:

function drawChart(dataController) {

  var resultSet = dataController.getCurrentData();
  ...
  var chartDataPoint;
  var chartLabel;
  var chartData = [];

  for (var i = 1; i <= resultSet.getRowCount(); ++i) {
   for (var j = 1; j <= resultSet.getColumnCount(); ++j) {
     chartDataPoint = resultSet.getOrdinalValue(i,j);
     chartLabel = resultSet.getOrdinalLabel(2,i);
     chartData[chartData.length] = { "country":chartLabel[0],"revenue":chartDataPoint};
    }
  }
  ...
}

The getCurrentData() method of the data controller returns another object, the result set object. That object provides methods for examining the results of the query. The example here shows some of them.

FeedbackOpens in a new tab