While working on forms if we get any requirement for select and deselect parent-child lines for e.g:
1. if parent record is selected then its child record should be selected automatically on the same form.
2. if child record is selected then its parent record should also be selected automatically on the same form.
[ExtensionOf(Formstr(SalesCopying))]
final class SalesCopying_Extension
{
/// <summary>
/// On Modified select child lines of the parent lines
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[formcontroleventhandler(formcontrolstr(salescopying, custinvoicetrans_copy), formcontroleventtype::modified)]
public static void custinvoicetrans_copy_onmodified(formcontrol sender, formcontroleventargs e)
{
custinvoicetrans custinvoicetrans;
formcheckboxcontrol parentcheckbox, childcheckbox;
formdatasource custinvoicetrans_ds;
int ismarked;
formcontrol formcontrol = sender as formcontrol;
custinvoicetrans_ds = formcontrol.formrun().datasource(tablestr(custinvoicetrans));
parentcheckbox = formcontrol.formrun().design(0).controlname("custinvoicetrans_copy");
ismarked = parentcheckbox.value();
custinvoicetrans_ds.next();
childcheckbox = formcontrol.formrun().design(0).controlname("custinvoicetrans_copy");
custinvoicetrans = custinvoicetrans_ds.cursor();
if(ismarked== 1)
{
childcheckbox.checked(1);
custinvoicetrans_ds.markrecord(custinvoicetrans, ismarked);
}
else
{
childcheckbox.checked(0);
custinvoicetrans_ds.markrecord(custinvoicetrans, ismarked);
}
custinvoicetrans_ds.refresh();
}
}
HEY HEY HEY!!!! HACK OF THE DAY!!!
If you want to call form standard function into event handler then implement event handler in form extension class.
Comments
Post a Comment