Jerry Kurtz
Jerry Kurtz

Reputation: 122

Acumatica - Dynamic combobox / dropdown list in a grid, based on value from another column

I have a grid where I need choices in the drop-down/combobox of one column to be based on the value of another grid column's value (in a combobox too, if that matters). This needs to occur for each row in the grid.

In this case, I would like to select "PO" or "SO" in the first column, and in the second column, have the list of choices depend on the value selected in the first column.

In case it helps, the choices would be a list of SO order types (can come from the SOOrderType table), or a list of PO doc types (possibly coming from the POOrderType.ListAttribute(), or hard-coded if need be).

I have tried using PXStringListAttribute:

PXStringListAttribute.SetList<MyDAC.moduleType>(cache, null, valValue.ToArray(), valDesc.ToArray());

and

PXStringListAttribute.SetList<MyDAC.moduleType>(cache, row, valValue.ToArray(), valDesc.ToArray());

I've tried these in FieldUpdated, RowSelected, FieldSelecting, and even in an attribute, but the behavior is consistent. When passing the "row" value as the second parameter, the choices do not show up. When passing null, the choices are the same for all rows.

I need the choices for each row to be dynamic and be based on a value in the column of the current/same row.

Any insight or help would be greatly appreciated.

Upvotes: 1

Views: 951

Answers (1)

Shamilla
Shamilla

Reputation: 246

Use PXStringListAttribute.SetList like how you did it in your second code snippet by passing in the row for the second parameter.

PXStringListAttribute.SetList<MyDAC.moduleType>(cache, row, valValue.ToArray(), valDesc.ToArray());

Then add the MatrixMode="true" property to the grid in the ASPX file.

<px:PXGrid ID="grid" runat="server" Height="400px" Width="100%" Style="z-index: 100" AllowPaging="True" AllowSearch="True" AdjustPageSize="Auto" DataSourceID="ds" SkinID="Primary" MatrixMode="true">

Setting MatrixMode to true will make it so contents of a column can be different for each row. In this case, it will allow the column to show different drop down values for each row in the grid. As a side note, you should only set MatrixMode to true when you need it because it could result in performance overhead.

Upvotes: 3

Related Questions