Using getFillteredRows in google charts with additional property

我们两清 提交于 2019-12-25 08:13:08

问题


I have a row structure like this

c:[
  { v: 'somevalue'},
  { v: 'somevalue'},
  { 
    v: 'somevalue',
    link: 'abc.com'
  }    
]

now I need all the rows which has link property present in 3rd column, is it possible using getFillteredRows function ?


回答1:


first, to use cell properties correctly, the structure would resemble the following...

c:[
  { v: 'somevalue'},
  { v: 'somevalue'},
  { 
    v: 'somevalue',
    p: {
      link: 'abc.com'
    }
  }    
]

to get or set the properties, use the following methods...

getProperty(rowIndex, columnIndex, name)

setProperty(rowIndex, columnIndex, name, value)

adding in getFilteredRows (spelling - one L in filter)...

use the test function, to find all the rows which has link property present in 3rd column

var rowsFound = data.getFilteredRows([{
  column: 2,
  test: function (value, row, column, table) {
    return (table.getProperty(row, column, 'link') !== null);
  }
}]);


来源:https://stackoverflow.com/questions/39944338/using-getfillteredrows-in-google-charts-with-additional-property

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!