Next
Update
Prev
View Data Collection Length

You can manipulate Grid data in the JavaScript function using the Collection object that can be created by calling the getCollection() method.

var gridApp, gridRoot, dataGrid, collection;
					
function gridReadyHandler(id) {
  gridApp = document.getElementById(id);
  gridRoot = gridApp.getRoot();

  gridApp.setLayout(layoutStr);
  gridApp.setData(gridData);

  var dataCompletedHandler = function(event) {
    dataGrid = gridRoot.getDataGrid();	// The grid object
    collection = gridRoot.getCollection();
  }
  
  gridRoot.addEventListener("dataComplete", dataCompletedHandler);
}

function showCollectionLength() {
  if (collection == null)
    collection = gridRoot.getCollection();
  if (collection == null) {
    alert("Cannot find the collection object.");
  return;
  }

  var clen = collection.getLength();
  var rowCount = 0;
  for (var i = 0; i < clen; i++) {
    var row = collection.getItemAt(i);
    rowCount++;
  }
  alert(clen + ":" + rowCount);
}

© 2017 KoolChart. All rights reserved.