I have a custom processing screen and the client wants the Selected column to be checked by default so users can just uncheck the rows they do not want to process. I’ve gently suggested they can just click the checkbox in the column header to select all with one click but that apparently is not acceptable for them. The filter defaults so that rows are populated on page load. I tried creating a view delegate and for loop to set the Selected column and this appears to work but has a side effect that it doesn’t detect the last one they’ve unchecked unless they click on another row so they’ve had some rows get processed unintentionally.
.
protected virtual IEnumerable detailsView()
{
PXView select = new PXView(this, true, DetailsView.View.BqlSelect);
Int32 totalrow = 0;
Int32 startrow = PXView.StartRow;
List<object> res = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches,
PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
PXView.StartRow = 0;
foreach (PXResult<PX.Objects.AP.Standalone.APQuickCheck> row in res)
{
PX.Objects.AP.Standalone.APQuickCheck check = (PX.Objects.AP.Standalone.APQuickCheck)row;
check.Selected = true;
DetailsView.Cache.Update(check);
}
return res;
}
Again, the view delegate sort of works but has some nasty side-effects. Any other ideas? I tried using RowSelecting but couldn’t get that to work either.
protected void APQuickCheck_RowSelecting(PXCache cache, PXRowSelectingEventArgs e, PXRowSelecting InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (PX.Objects.AP.Standalone.APQuickCheck)e.Row;
// default to selected upon reading from database
if (row != null)
{
row.Selected = true;
}
}