Difference between revisions of "Documentation/DevGuide/Forms/Filtering and Sorting"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (1 revision(s))
m
Line 9: Line 9:
 
Forms support quick and easy filtering and sorting like the underlying row sets. For this, the properties [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#Filter com.sun.star.sdb.RowSet:Filter], [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#ApplyFilter com.sun.star.sdb.RowSet:ApplyFilter] and [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#Order com.sun.star.sdb.RowSet:Order] area used.  
 
Forms support quick and easy filtering and sorting like the underlying row sets. For this, the properties [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#Filter com.sun.star.sdb.RowSet:Filter], [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#ApplyFilter com.sun.star.sdb.RowSet:ApplyFilter] and [http://api.openoffice.org/docs/common/ref/com/sun/star/sdb/RowSet.html#Order com.sun.star.sdb.RowSet:Order] area used.  
 
<!--[SOURCE:Forms/SalesFilter.java]-->
 
<!--[SOURCE:Forms/SalesFilter.java]-->
 
+
<source lang="java">
 
   // set this as filter on the form
 
   // set this as filter on the form
 
   String sCompleteFilter = "";
 
   String sCompleteFilter = "";
Line 22: Line 22:
 
   XLoadable xLoad = (XLoadable)UnoRuntime.queryInterface(XLoadable.class, m_xSalesForm);
 
   XLoadable xLoad = (XLoadable)UnoRuntime.queryInterface(XLoadable.class, m_xSalesForm);
 
   xLoad.reload();
 
   xLoad.reload();
 
+
</source>
 
In this fragment, a filter string is built first. The "<code>SALEDATE >= {D '2002-12-02'}</code>" is an example for a filter string. In general, everything that appears after the WHERE clause of an SQL statement is set as a <code>Filter</code> property value. The same holds true for the <code>Order</code> property value and an <code>ORDER BY</code> clause.
 
In this fragment, a filter string is built first. The "<code>SALEDATE >= {D '2002-12-02'}</code>" is an example for a filter string. In general, everything that appears after the WHERE clause of an SQL statement is set as a <code>Filter</code> property value. The same holds true for the <code>Order</code> property value and an <code>ORDER BY</code> clause.
  

Revision as of 20:21, 6 April 2008



Forms support quick and easy filtering and sorting like the underlying row sets. For this, the properties com.sun.star.sdb.RowSet:Filter, com.sun.star.sdb.RowSet:ApplyFilter and com.sun.star.sdb.RowSet:Order area used.

  // set this as filter on the form
  String sCompleteFilter = "";
  if ((null != sOdbcDate) && (0 != sOdbcDate.length())) {
      sCompleteFilter = "SALEDATE >= ";
      sCompleteFilter += sOdbcDate;
  }
  m_xSalesForm.setPropertyValue("Filter", sCompleteFilter);
  m_xSalesForm.setPropertyValue("ApplyFilter", new Boolean(true));
 
  // and reload the form
  XLoadable xLoad = (XLoadable)UnoRuntime.queryInterface(XLoadable.class, m_xSalesForm);
  xLoad.reload();

In this fragment, a filter string is built first. The "SALEDATE >= {D '2002-12-02'}" is an example for a filter string. In general, everything that appears after the WHERE clause of an SQL statement is set as a Filter property value. The same holds true for the Order property value and an ORDER BY clause.

Template:Documentation/Tip

Then the ApplyFilter property is set to true. This is for safety, because the value of this property is unknown when creating a new form. Every time you have a form or row set, and you want to change the filter, remember to set the ApplyFilter property at least once. Afterwards, reload() is called.

In general, ApplyFilter allows the user of a row set to enable or disable the current filter quickly without remembering it. To see what the effects of the current filter are, set ApplyFilter to false and reload the form.

Content on this page is licensed under the Public Documentation License (PDL).
Personal tools