1. #1
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Question Answered: How to sort a column with an IdentityValueProvider<T>?

    Answered: How to sort a column with an IdentityValueProvider<T>?


    I was told that if I needed to render a column using more than one property on a bean to do the following:

    Code:
    ColumnConfig<Foo, Foo> cc = new ColumnConfig(new IdentityValueProvider<Foo>(), ...);
    The problem I'm seeing is that when I got to sort this column, no sort info gets sent to the server so the server doesn't know what column to sort by. With a PropertyAccess<T> implementation, it uses the interface method name as the column name to sort by and this is what's sent to the server.

    What can I do to have something sent to the server to indicate this column?

  2. Yes. It's the value returned by IdentityValueProvider.getPath(). I hadn't realized I never posted a solution. Sorry about that. It's been a while.

  3. #2
    Touch Premium Member
    Join Date
    Mar 2008
    Location
    Morgan Hill, CA
    Posts
    126
    Vote Rating
    3
    margozzi is on a distinguished road

      0  

    Default


    Did you ever solve this problem? I am facing the exact same issue.

  4. #3
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    Yes. It's the value returned by IdentityValueProvider.getPath(). I hadn't realized I never posted a solution. Sorry about that. It's been a while.

  5. #4
    Touch Premium Member
    Join Date
    Mar 2008
    Location
    Morgan Hill, CA
    Posts
    126
    Vote Rating
    3
    margozzi is on a distinguished road

      0  

    Default


    Thank you for the prompt reply. This is what I ended up doing with success:

    Code:
    ColumnConfig<Job, Job> stateColumn = new ColumnConfig<Job, Job>(new IdentityValueProvider<Job>("state"), 100, _jobConstants.state());

  6. #5
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Answers
    20
    Vote Rating
    21
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    The one downside with that what you have currently is that the cell renderer will, by default, just call Job.toString() for the contents of the cell. This is most likely not what you want.

    If Job.toString() does return what you want I might question your usage of the method as it is typically used for debugging and logging. Sure, you can make it do whatever you want, but I tend to really dislike APIs that rely on toString() for anything that is remotely related to business-logic.

    You will need a custom cell renderer, probably one that extends AbstractCell<Job> to define exactly what you want to display. If you go this route, GWT recommends you check for a null object when you implement the render(...) method.

    Please let us know if you need additional help.

  7. #6
    Touch Premium Member
    Join Date
    Mar 2008
    Location
    Morgan Hill, CA
    Posts
    126
    Vote Rating
    3
    margozzi is on a distinguished road

      0  

    Default


    Yes, Sorry, I did not include the code that implemented the AbstractCell<Job> in the above snippet.
    I was unable to figure out where the getPath() was supposed to go. I eventually discovered I could pass it in the constructor. I wanted to post that in case other came after me looking for the solution.

Thread Participants: 1

Tags for this Thread