Announcement

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

    ListGrid filter does not work

    Hello,

    I have a ListGrid which is filled with ListGridRecords. The ListGridRecords are of a special type:

    Code:
    public class RecordContainer<T> extends ListGridRecord
    {
      private T data;
    }
    The RecordContainer class contains data objects like the following:

    Code:
    public class Employee {
    
      String name;
      String password;
      int age;
    
    }
    I am displaying the Employee data in a ListGrid which works fine. But if I enter a filter value in my ListGrid and press enter, nothing happens. This isn't surprising at all since the filter does not understand the data objects. How can I use filtering with custom data objects?

    I managed to enable sorting this way:

    Code:
        nameField.setSortNormalizer( new SortNormalizer() {
    
          @Override
          public Object normalize( ListGridRecord record, String fieldName )
          {
            RecordContainer<Employee> employeeRecord = (RecordContainer<Employee>) record;
            Employee employee = employeeRecord.getData();
            return employee .getName();
          }
          
        });
    Maybe something similar exists for filtering?
    Last edited by jballh; 9 Jul 2009, 02:30.

    #2
    Very very bad approach. Abandon it unless you want to do 6x the work for an inferior final result.

    Comment


      #3
      Hello Isomorphic,

      I'm sad to hear you don't like my approach. I know it's not pretty, but I thought it could save some work.

      Will filtering be possible if I go the standard way and create an EmployeeRecord class?

      Comment


        #4
        Dear jballh

        I have the same problem in filtering, could you please hep me if you already solved it, thanks

        Comment


          #5
          I think I have a similar problem here. I have a query with three table join. It is a table of a child that has another child.

          ProductLine
          id
          productLineName

          Product
          id
          product_line_id
          productName

          Install
          id
          product_line_id
          product_id
          installName

          When I setup the DS I can set qualifyColumnNames="false" or "true"

          If I set to false. I get an "Ambiguous Error" because of the same name so the filter does not work. If I switch the flag to "true" the heading sort does not want to work because the SQL it wants to send is install.productLineName. Which does not exist in the child table.

          Let know what your thought is on this beside me changing the install.product_line_id on the DB or dropping it from the table entirely.


          TIA,
          Last edited by ttran; 21 Jan 2011, 13:55.

          Comment


            #6
            Once again, this approach will not work. Data values to be used by the grid must be placed in ListGridRecord objects via setAttribute(), then all functions of the grid work without further effort.

            You can create convenience classes that provide type-specific setters and then call ListGridRecord.setAttribute() (as shown in many samples), but you should not attempt to adapt the ListGrid to classes that store data values as Java properties. They must be stored via setAttribute().

            Comment


              #7
              I think you still lost me. I have a DS so I don't have any Java object. On the DS currently I am setting the qualifyColumnName="true". That fixed my ambiguous issue. However, when I click on the column heading to to the name sort, the sort is trying to issue a SQL statement on the child table for the name of the parent table. But this does not exist b/c we are using foreign key refence. What I wanted to know is why sort still wanted to issue this query when we obviously changed the customSQL to point to the parent table. I was hoping there is a simpple mapping statement that can fix this. If you are saying I can do this with setAttribute then what/where should I set this?

              TIA,

              btw, what I have to do now is setSortByDisplayField(false). However, this is not a proper sort because it is base on the ID not the name.

              Comment


                #8
                I think I got this to work. It was exactly what I thought it would. Another word we have to define the change the name qualify table name somehow. However it was easier than I thought. I just needed to add the tableName attribute to the name field.

                <field name="productname" type="text" customSQL="true" tableName="esd_product_line"/>

                Comment

                Working...
                X