BCS Position Data Grid XE3

Initially we need to provide a mechanism to gather input information from the user. I have chosen to the InputBox control. The information from the InputBox control is then used to filter the data. The following code snippet shows how this process is completed.

procedure TBCSPwbLaunchC.FilterDatabase1Click(Sender: TObject);
  BCSPwbLaunchdm.atapwb.Filter := 'sdes LIKE ' + '''' +
    trim(InputBox('Enter Initial Value', 'Key In Initial Value', '')) +
    '%' + '''';
  BCSPwbLaunchdm.atapwb.Filtered := true;

Notice the ‘%’ appended to the filter string.  This per cent sign is the wild card designation for the filter.  The filter as coded tells the data table to return all records that begin with the string entered via InputBox with trailing information but do not include records that are less than or greater than the inputted string.

Conversely when we would like to turn off the filtering mechanism for the data records simply tell the table not to use a filter for the data by setting the Filtered option on the data component to false. The following code show how this is accomplished.

procedure TBCSPwbLaunchC.ShowAllRecords1Click(Sender: TObject);
  BCSPwbLaunchdm.atapwb.Filtered := False;

The following video demonstrates this feature in action.

The following filter examines the data field where the contains the specified string.  Notice the % before and after the keyed information specifies the contains filter.

  Procedure: Contains1Click
  Date:      15-Dec-2013
  @Param     Sender: TObject
  @Return    None
procedure TBCSPwbLaunchC.Contains1Click(Sender: TObject);
  dcmd: string;
  dcmd := trim(InputBox('Enter Contains Value Now!',
    'Key In Contains Value!', ''));
  if trim(dcmd) > '' then
    BCSPwbLaunchdm.atapwb.Filter := 'sdes LIKE ' + '''' + '%' + dcmd +
      '%' + '''';
    BCSPwbLaunchdm.atapwb.Filtered := true;

Of all the approaches to quickly position the user to a specific set of records in the data table I have found this approach to be the most efficient.

If you believe you have a more improved approach to this problem please feel free to share with us by adding your comments to this post.

Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.

Leave a Reply