I have a json from an api and want to create from this a table.
I have created my table with the corresponding cells. But I have now the problem to fill the table wit text. If I try to iterate over the cells, rows or columns i have everytime the problem that I can’t iterate because its a object. Also something like
myTable.cell doesn’t work to select the second cell or column etc.
Is there any best practise to fill the table with text?
Gonna need to see code examples to help here; although it sounds like a vanilla JS issue rather than UXP.
You are talking about the InDesign DOM, not JSON, correct?
Most InDesign objects are probably XPath or something based objects, not iterable. To make it easier to iterate, change them to static array like this. Then you can use map, filter, and other useful features.
const cellsArray = myTable.cells.everyItem().getElements() ;
I expect that
myTable.cell would work if changed as follows.
myTable.cells ; // cell**s**
@sttk3 thanks your code with
makes it really easier.
Oh man I hate theese dumb mistakes like missing the plural s .
@Timothy_Bennett your right it seems the vanilla js solution from sttk3 makes easier for me.