Migx - multiple dataIndex possible?

Just wondering about the MIGX Grid area as it displays in the Manager in the Template Variables tab - is it possible to call different dataIndex sources for the same grid column, depending which one is not empty?

Say, the caption is ‘Image’ but sometimes the image might be in ‘cell_1_image’ field, sometimes in ‘cell_2_image’

So rather than

“header”: “Image”,
“dataIndex”: “cell_2_image”

you’d have

“header”: “Image”,
“dataIndex”: “IF cell_1_image is not empty, then ‘cell_1_image’, ELSE if cell_2_image is not empty, then ‘cell_2_image’”

…kind of thing, a bit like a Modx output modifier or some such. We have different formnames all using the same grid, but not all form names have the data in the same format. We’re trying to get one grid display to suit all forms.

Modx 2.8.1 Migx 2.11.0

To achieve this, go to the “Renderer” tab when you edit the columns, choose this.renderChunk in the “Renderer” dropdown and in the field “renderChunk template” enter code like this:

[[+cell_1_image:isempty=`[[+cell_2_image]]`]]
1 Like

Harry to the rescue again. Thanks!