我在处理页面的过滤器部分有一个字段,它不会影响行的选择,但会确定如何处理行。我创建了一个公共变量并将其设置在filter row selected事件上,但是当再次调用Graph来处理行时,它似乎被重置。单击“处理”不会导致行选定方法触发。我一直在寻找一种在处理方法中访问过滤器缓存的方法,但我没有成功。如何保存此值或从处理方法访问过滤器缓存?
答案 0 :(得分:1)
您必须在委托闭包中捕获过滤器值。这是我用来做的模式:
PXFilter<ProcessFilter> filter;
public void ProcessFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
ProcessFilter filter = e.Row as ProcessFilter;
if (filter != null)
{
DataView.SetProcessDelegate(delegate (List<DAC> dacRecords)
{
ExecuteProcess(filter, dacRecords);
});
}
}
public static void ExecuteProcess(ProcessFilter filter, List<DAC> dacRecords)
{
// filter should contain the value captured at closure
// when calling SetProcessDelegate
// You have to create a new graph to process the DAC Records
YourGraph newGraph = PXGraph.CreateInstance<YourGraph>();
foreach (DAC dacRecord in dacRecords)
{
// Use newGraph to modify the records
}
// Save newGraph to persist the changes
}