Skip to main content
Solved

Create a method for a button that filters a grid.

  • 18 July 2024
  • 2 replies
  • 44 views

I need to create a method that is triggered by a button. I already have the button mapped, and I just need to complete the function, but I've encountered some complications.

For example, I want to filter only the ones marked in red to show only '6', and if I press again, it should return to its original state. This data is in string format.

 [PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "FilterGoformz")]
protected void filterGoformz()
{
//Logic
}

Thank you for your attention

2 replies

Badge +12

There are probably multiple ways you could do this, but I would suggest adding an unbound field to the header of the record (looks like an Opportunity). Change your data view for this grid to show all records OR only records equaling ‘6’ when the unbound field is true. Then use your button to set / unset the unbound field.

Alternatively, if, for some reason, you wanted to persist the filtering across records, you could also make the field bound, which would allow the record to store whether the user wants it to remain filtered.

Userlevel 7
Badge +19

Yes, Introduce Unbound fields in the header section and write a delegate to filter the records in the grid.

I don’t think button is required to filter the data in the grid. Here is an example to work with delegates.

https://asiablog.acumatica.com/2016/06/using-pxview-in-dataview-delegate.html

Reply