Tuesday, November 13, 2012
Creating a custom instant search filter
1. In the AOT, open the MainAccountListPage form and add a new StringEdit
control with the following properties to the existing Filter group:
Property Value
Name FilterName
AutoDeclaration Yes
ExtendedDataType AccountName
2. Override its textChange() method with the following code:
public void textChange()
{
super();
MainAccount_ds.executeQuery();
}
3. Override the control's enter() method with the following code:
public void enter()
{
super();
this.setSelection(strLen(this.text()), strLen(this.text()));
}
4. Override the executeQuery() method of the MainAccount data source with the
following code:
public void executeQuery()
{
QueryBuildRange qbrName;
qbrName = SysQuery::findOrCreateRange(this.queryBuildDataSource(),
fieldNum(MainAccount,Name));
qbrName.value(FilterName.text() ? '*'+queryValue(FilterName.text())+'*' : SysQuery::valueUnlimited());
super();
}
5. In order to test the search, open General ledger | Common | Main accounts
and start typing in the Account name filter. Notice how the account list is being
filtered automatically:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment