Next
Prev

The properties can be set dynamically using JavaScript. This sample Grid demonstrates how to set the cell property in the Grid using JavaScript.

var gridApp, gridRoot, dataGrid, collection;

function gridReadyHandler(id) {
  gridApp = document.getElementById(id);
  gridRoot = gridApp.getRoot();
  
  gridApp.setLayout(layoutStr);
  gridApp.setData(gridData);
  
  function layoutComplete() {
    dataGrid = gridRoot.getDataGrid();
    setSpanAttributes();
  }
  gridRoot.addEventListener("layoutComplete", layoutComplete);
}

function setSpanAttributes(columnNo, check) {
  if (collection == null)
    collection = gridRoot.getCollection();
  if (collection == null) {
    alert("The collection object cannot be found.");
    return;
  }

  collection.addRowAttributeDetailAt(4, "subTotalStyle", "#DDDDDD", "#,##0", true, 40);

  collection.addCellAttributeDetailAt(0, 0, 12, 1);
  collection.addCellAttributeDetailAt(12, 0, 12, 1, "subTotalStyle", "#FFCC00");
  for (i = 0; i < collection.getLength(); i++) {
    if (i % 3 == 0)
      collection.addCellAttributeDetailAt(i, 1, 3, 1);
    }
  }
}

© 2017 KoolChart. All rights reserved.