Next
Update
Prev
Change Data
Original Data

You can manipulate Grid data in the JavaScript function using the Collection object that can be created by calling the getCollection() method. This sample Grid demonstrates how to change the data in the cell. Click the button (Change Data) below the sample Grid, then you will find the data in the Seoul column updated.

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();
    collection = gridRoot.getCollection();
  }

  gridRoot.addEventListener("dataComplete", dataCompletedHandler);
}

function resetItemField() {
  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 fv = gridRoot.getItemFieldAt(i, "Seoul");
    fv++;
    gridRoot.setItemFieldAt(fv, i, "Seoul");
  }
}

function setJSONData() {
  gridApp.setDataType("json");
  gridApp.setDataURLEx("./Data/DataOneDepthRevenues.txt");
}

© 2017 KoolChart. All rights reserved.