GridDataProvider.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2017
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', 'underscore'], function (Class, _) {
  8. 'use strict';
  9. var GridDataProvider = Class.extend({
  10. _data: null,
  11. _numRows: null,
  12. _numColumns: null,
  13. init: function init(data) {
  14. if (data) {
  15. this._data = data;
  16. this._setDataDimensions();
  17. }
  18. },
  19. getNumRows: function getNumRows() {
  20. return this._numRows;
  21. },
  22. getNumColumns: function getNumColumns() {
  23. return this._numColumns;
  24. },
  25. getValue: function getValue(rowIndex, columnIndex) {
  26. return this._data[rowIndex][columnIndex];
  27. },
  28. _setDataDimensions: function _setDataDimensions() {
  29. if (this._data) {
  30. this._numRows = this._data.length;
  31. this._numColumns = _.isArray(this._data[0]) ? this._data[0].length : 0;
  32. }
  33. },
  34. updateData: function updateData(data) {
  35. if (data) {
  36. this._data = data;
  37. this._setDataDimensions();
  38. }
  39. }
  40. });
  41. return GridDataProvider;
  42. });
  43. //# sourceMappingURL=GridDataProvider.js.map