This achievement is not my invention as followed from another blog. This was very good and worked for me. :)
Requirement:Add options "Filter By Field", "Filter By Selection" and "Remove Filter" in a display field "Name".
Steps:
1. Make "Name" control as Auto declaration to YES
2. Override context method in the same control and paste the following code: This form is having data from Employee details.
Requirement:Add options "Filter By Field", "Filter By Selection" and "Remove Filter" in a display field "Name".
Steps:
1. Make "Name" control as Auto declaration to YES
2. Override context method in the same control and paste the following code: This form is having data from Employee details.
public void context()
{
int selectedMenu;
formrun SearchformRun;
Args arg;
Name strtext;
querybuilddataSource querybuilddataSource;
queryrun qr;
query q;
PopupMenu menu = new
PopupMenu(element.hWnd());
int a =
menu.insertItem('Filter By Field');
int b =
menu.insertItem('Filter By Selection');
int c =
menu.insertItem('Remove Filter');
;
q = EmplTable_ds.query();
querybuilddataSource =
q.dataSourceTable(tablenum(EmplTable));
querybuilddataSource =
querybuilddataSource.addDataSource(TableNum(DirPartyTable));
querybuilddataSource.addLink(FieldNum(EmplTable,PartyId),FieldNum(DirPartyTable,PartyId));
selectedMenu = menu.draw();
switch(selectedMenu)
{
case -1: //Filter by
field
break;
case a:
arg = new
args('SysformSearch');
SearchformRun =
new formrun(arg);
SearchformRun.run();
SearchformRun.wait();
//Reading User
entered value for filter process
strtext =
SearchformRun.design().controlName('FindEdit').valueStr();
if(strtext)
{
//Creating a
query for filter
querybuilddataSource.addRange(FieldNum(DirPartyTable,Name)).value(strtext);
EmplTable_ds.query(Q);
EmplTable_ds.executeQuery();
}
break;
case b: //
Filter By Selection
querybuilddataSource.addRange(FieldNum(DirPartyTable,Name)).value(smylEmplName.valueStr());
EmplTable_ds.query(Q);
EmplTable_ds.executeQuery();
break;
case c : //
Remove Filter
q = new Query();
querybuilddataSource = q.addDataSource(tablenum(EmplTable));
querybuilddataSource.clearLinks();
querybuilddataSource.clearRanges();
EmplTable_ds.query(Q);
EmplTable_ds.removeFilter();
break;
Default:
break;
}
}
|