Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    One-to-Many and search by item question

    Hi,
    I have @OneToMany relation (Invoice-InvoiceItems) and need to search by item fields (InvoiceItem.description).
    So I created datasource accordingly, have FilterBuilder and Listgrid attached to this datasource.
    User may choose InvoiceItem description field in the FilterBuilder fields list and fill criteria.
    This is working fine (server can filter by item fields) as far as client does not have all records in its cache. If it does then it tries to filter locally and fails obviously.
    I do not want to turn client side filtering all together for this listgrid (assume that item searching would be rare), so I am thinking about setting ResultSet.useClientFiltering flag to false just before setting criteria for the listgrid, but only when criteria include item filtering.
    Is it the right approach ? Any other/better ideas ?
    Thanks
    MichalG

    #2
    Generally the right way to do this is to use dataSourceField.includeFrom to do the equivalent of a SQL join. Then all fields (whether on invoice or items) are represented as fields of a single DataSource and client-side filtering will work.

    Otherwise, you will just need to turn client-side filtering off. Turning it on and off dynamically isn't supported (think it through - lots and lots of ambiguous cases for what it supposed to happen).

    Comment


      #3
      I did not know that dataSourceField.includeFrom covers One-to-Many situation and client side filtering!?
      According to the docs:
      "A foreignKey declaration must exist between the two DataSources, establishing either a 1-to-1 relationship or a many-to-1 relationship from this DataSource to the related DataSource"
      MichalG

      Comment


        #4
        If you're saying that your search interface allows searching on InvoiceItem fields but the InvoiceItems are not shown as rows in the resulting grid, then no, includeFrom won't handle this situation.

        Comment


          #5
          Originally posted by Isomorphic View Post
          If you're saying that your search interface allows searching on InvoiceItem fields but the InvoiceItems are not shown as rows in the resulting grid, then no, includeFrom won't handle this situation.
          Yes.

          So looks like that disabling client filtering is the only option in this situation.
          Thanks,
          MichalG

          Comment

          Working...
          X