无法通过javascript访问ag-grid中的数据

时间:2019-04-26 14:17:12

标签: javascript ag-grid

我正在使用每个javascript使用ag-grid从网站访问某些数据,除非将它们滚动到视口中,否则无法抓取视口中不存在的行。我在每个单元格上触发了focus()事件,它以这种方式自动滚动。 我设法使用脚本来做到这一点,但是它有点慢,是否有更好的解决方案来访问ag-grid的数据,而无需集中/滚动?

这是我当前的脚本:

// extract number of rows
var rows = parseInt(document.evaluate("//*[@class='ag-status-panel-filtered-row-count']/child::*[@class='data_rows']",document.body, null, 9, null).singleNodeValue.textContent);

var list_data = [];
// iterate rows and extract data from cell
for (i=0; i < value; i++) {
  document.evaluate(`//*[@row-index='${i}']/descendant::*[@role='gridcell' and @col-id='data_to_extract']`,document.body, null, 9, null).singleNodeValue.focus();
  list_data.push(document.evaluate(`//*[@row-index='${i}']/descendant::*[@role='gridcell' and @col-id='data_to_extract']`,document.body, null, 9, null).singleNodeValue.textContent);
  }

0 个答案:

没有答案