Skip to main content
Question

How can I conditionally enable a button in the Modern UI, based on the active row?

  • September 19, 2025
  • 4 replies
  • 86 views

darylbowman
Captain II
Forum|alt.badge.img+15

I know of two ways to accomplish this:

  1. Enable SyncPosition on the grid which will trigger the RowSelected event in the graph
  2. Use the TypeScript CurrentRowChanged event

Here’s the problem: all the examples in the docs are for base screens, not customizations. I need to do this for an existing grid without SyncPosition enabled.

I tried defining it in an extension of the original class:

@gridConfig({
syncPosition: true
})
export class DXCostBudgetExt extends CostBudget {

This didn’t seem to change anything.

 

I also tried to write a TypeScript event handler for CurrentRowChanged, but again, the docs only specify how to do this with the base class, not an extension class. I tried several variations of this, and nothing seems to work:

@handleEvent(CustomEventType.CurrentRowChanged, { view: "CostBudget" })
onCostBudgetLineChanged(args: CurrentRowChangedHandlerArgs<PXViewCollection>) {
const ar = args.viewModel.activeRow as DXCostBudgetExt;
//const model = (<any>args.viewModel as CostBudget);

if (ar.UnlinkPO) {
ar.UnlinkPO.enabled = !!ar?.UsrPDPONbr?.value;
}
}

 

4 replies

darylbowman
Captain II
Forum|alt.badge.img+15
  • Author
  • September 19, 2025

In \src\screens\SO\SO301000\extensions\SO301000_Manufacturing.ts I found an example, which lead me to this:

export interface PM301000_MyProject extends PM301000 { }
export class PM301000_MyProject {

@handleEvent(CustomEventType.CurrentRowChanged, { view: "CostBudget" })
onCostBudgetLineChanged(args: CurrentRowChangedHandlerArgs<PXViewCollection<CostBudget>>) {

const model = args.viewModel as PXViewCollection<DDXCostBudgetExt>;
const ar = args.viewModel.activeRow as DXCostBudgetExt;
if (model.UnlinkPO) {
model.UnlinkPO.enabled = !!ar?.UsrPDPONbr?.value;
}
}
}

This works.


darylbowman
Captain II
Forum|alt.badge.img+15
  • Author
  • September 19, 2025

This still didn’t solve my problem completely because I was using RowSelected to disable the button conditionally, which prevented TypeScript from enabling it. I could be doing something wrong, but I noticed that on the Sales Order screen, ‘PO Link’ is disabled in TypeScript for the Modern UI and in ASPX (by DependOnGrid and StateColumn) in the Classic UI.

I was going to do the same, but I noticed that several other places in the source code, they are simply using a RowSelected TypeScript event handler to disable buttons. I’m not sure when this fires. I tried to do the same, but it isn’t working. I’m also curious if there’s a best practice between these two (assuming both are valid options).


Chris Hackett
Community Manager
Forum|alt.badge.img
  • Acumatica Community Manager
  • November 5, 2025

Hi ​@darylbowman were you able to find a solution? Thank you!


darylbowman
Captain II
Forum|alt.badge.img+15
  • Author
  • November 5, 2025

I don’t think so.