Thursday 21 November 2013

Adding Custom filters on from


Some time we have requirement to create custom filter on form with checkbox, stringControl and ComboBox with lookup like smmContactPerson form. So we can complete this requirement with simple process. In this post I will create all filters on “CustTable” Table step by step.
Setp1-Declare two “str” variables in form Class declaration(str   custNameFilter, accountFilter). And create these controls on form according figure1
1. CheckBoxFilter(CheckBox)
        AutoDeclaration – Yes
        Lable- ShowAll
2. NameFilter (StrinEdit)
        AutoDeclaration - Yes
        Lable-Name
3.  AccountNumFilter (StrinEdit)  
        AutoDeclaration - Yes
          ExtendedDataType-CustAccount


Figure 1 - Create FormControls

Setp-2  Override modified() on CheckBoxFilter control and write code:
if(ret)
              {
                      CustTable_ds.executeQuery();
              }

Setp2 – override enter() method on NameFilter control and
super();  
this.setSelection(strlen(this.text()), strlen(this.text()));

Setp3 – override textchange() method on NameFilter  control and call modified().
             this.modified();

Setp4 – override modified() on NameFilter  control and wirte code:
 nameFilter = ‘*’+this.text()+’*’
 CustTable_ds.ExecuteQuery();

 Figure 2 - Override methods on FormControls

Setp5 – Finally override ExecuteQuery()on FormDataSoruce under CustTable and write code:
    public void executeQuery()
     {
       QueryBuildDataSource        qbds = CustTable_ds.query().dataSourceTable(tablenum(CustTable));
       QueryBuildRange      qbr1 = SysQuery::findOrCreateRange(qbds, fieldnum(CustTable, Blocked));
       QueryBuildRange      qbr2 = SysQuery::findOrCreateRange(qbds, fieldnum(CustTable, Name));
       QueryBuildRange      qbr3 = SysQuery::findOrCreateRange(qbds, fieldnum(CustTable, AccountNum));
       ;
 
       qbr2.value(custNameFilter);
       qbr3.value(accountFilter);
       if(CheckBoxFilter.value())
         {
                   qbr1.value(SysQuery::valueNot(CustVendorBlocked::No));
         }
       else
        {
                  qbr1.value(SysQuery::valueUnlimited());
        } 
      super();
    }

1 comment:

  1. what is use of Adding Custom filters on from? can u please share one scenario ?

    ReplyDelete