Our blazing fast Grid component built with pure JavaScript


Post by bensullivan »

Hi

How do I iterate through a records column (type = percent) values including the ones that are 0%? record.data only seems to have the columns that have been set and Object.keys(record) does not display the missing columns either.

Thanks

Ben

Post by Maxim Gorkovsky »

Hello.
I'm afraid it is not clear what are you trying to iterate, row values visible in the grid or values of the column of a certain type.

It might be difficult to iterate row cells: column decides what to render in the cell and that value is written to the DOM element. So, in case there is a renderer, you will have to either iterate over visible columns, triggering rendering, or query DOM for cell content. But for a simple case when you just put record value to the cell, you can do it using visibleColumns property:
grid.columns.visibleColumns.forEach(column => {
  let value = record[column.field]
})
Iterating column values is similar, using forEach:
grid.store.forEach(record => {
  let value = record[column.field]
})

Post by bensullivan »

Thanks Maxim - I will give visibleColumns a try..

Thanks

Ben

Post Reply