I have a grid that looks like this:
When I click + to add a new line item, I want to default the value in the Greater Than field to the Less Than value in the previous line.
I can get it to work, but no matter which event handler I use, it only will do the update to the field AFTER I leave the line.
Enter 6000 in the less than field
Tab out of the line and the 5000 gets populated.
I am using the FieldDefaulting handler to get the previous line and update the newvalue for the row being defaulted.
NOTE...this code WORKS, but it only fires AFTER you leave the line. When the current row has a SortOrder of zero, this tells me that this is a new row and to get the previous row.
protected void ICSPricingMatrix_FromPrice_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
{
var row = (ICSPricingMatrix)e.Row;
if (row == null) return;
if (row.SortOrder == 0)
{
ICSPricingMatrix prevItem = SelectFrom<ICSPricingMatrix>
.Where<ICSPricingMatrix.priceClassID.IsEqual<@P.AsString>>.AggregateTo<Max<ICSPricingMatrix.sortOrder>>
.View.Select(this, row.PriceClassID);
if (prevItem != null)
{
e.NewValue = prevItem.ToPrice;
}
}
}
Shouldn’t FieldDefaulting fire as soon as I click the plus sign? What the heck does fire when you click the plus sign?
Best answer by Naveen Boga
View original