I can't workout this seemingly simple task. I have a custom CheckBox named PrintAll and what I want is once it gets selected, all rows in a grid gets selected/highlighted. Here's what I have tried:
Option 1: Passing CTRL+SHIFT+END. The example below passes CTRL+A combination.
public boolean modified()
{
boolean ret;
ret = super();
#task
if(PrintAll.value())
{
// CTRL+A
element.task(#taskSelectAll);
}
return ret;
}
Result: selects only loaded records, so say 20 out of 500. If you scroll down, it keeps selecting upcoming ones.
CTRL+SHIFT+END combination works from UI, although it gives this Box::yesNo:
You cannot select all lines including the last one, as not all the lines have been loaded at the present time. Loading all the lines may take some time!
Do you want to continue selecting lines and to load all lines now?
When I tested what taskid
CTRL+SHIFT+END gets, it appears that it gets 2842, unfortunately using this id in code as element.task(2842);
highlights only the first record.
So if instead of CTRL+A I could submit CTRL+SHIFT+END properly, the problem would be solved.
EDIT: (PARTIAL SOLUTION) Running element.task(2842);
twice gets me to the warning above, so I can click Yes and select all the lines. Does anyone know how could I bypass this warning?
Option 2: Trying various properties of the form and data sources to make it to load all the records available and not the first 20.
Result: nothing has worked.
Option 3: Perhaps the CheckBox, which can be found on some forms as a first field and which, once selected, selects all the records, could do the same, but I can't find how to add it to my custom form? Although perhaps this option select loaded records only too, so it won't make a difference to what I have now.
This is what finally worked for me (source). Please note, that InventDim wasn't my main Data Source in this form. InventTransOrigin was the one, but it didn't worked.
So I guess, you can have this method if you don't want to show any warnings to the end user:
public boolean modified()
{
InventDim inventDimTMP;
boolean ret;
ret = super();
if(PrintAll.value())
{
inventDimTMP = InventDim_DS.getFirst();
while(inventDimTMP)
{
InventDim_DS.findRecord(inventDimTMP);
InventDim_DS.mark(true);
inventDimTMP = InventDim_DS.getNext();
}
}
return ret;
}
OR this one if you want them to see the warning mentioned above:
public boolean modified()
{
boolean ret;
ret = super();
if(PrintAll.value())
{
// Marks first record
element.task(2842);
// Marks all records
element.task(2842);
}
return ret;
}