Success! Looks like we've fixed this one. According to our records the fix was applied for EXTGWT-2652 in a recent build.
  1. #1
    Sencha Premium Member
    Join Date
    Dec 2012
    Posts
    5
    Vote Rating
    0
    noahtalmadge is on a distinguished road

      0  

    Default No setSortField() method for ListStore, loss of functionality from GXT 2.x

    No setSortField() method for ListStore, loss of functionality from GXT 2.x


    Required Information

    Version(s) of Ext GWT
    GXT 3.0.1 GPL

    Browser versions and OS
    (and desktop environment, if applicable)
    NA

    Virtual Machine
    NO

    Description
    In GXT 2.x there was the ability to set what the initial sort state of the store for a grid was to match the presorting of the list. For example, if the list was pre-sorted by name asc you could tell the store that was the case so you would not have to initailly click on the column header twice to get a sort desc since the first click would trigger a sort asc which the list was already sorted as such.

    Run mode
    Both

    Steps to reproduce the problem
    1. Create a liststore with models that have a name string field
    2. Sort the liststore by the name field asc
    3. add the store to a grid with a name column
    4. click on the name column header - nothing happens
    5. click on the name column header again - the list is now sorted desc

    Expected result
    The first click would result in the correct sort of being opposite of the current sort sate i.e. if sorted asc would be desc now.

    Actual result
    Must click twice on column header instead of once.

    Test case
    import java.util.ArrayList;
    import java.util.List;

    import org.swis.noah.client.Person.PersonProperties;

    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.core.client.GWT;
    import com.google.gwt.editor.client.Editor.Path;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.sencha.gxt.core.client.ValueProvider;
    import com.sencha.gxt.data.shared.ListStore;
    import com.sencha.gxt.data.shared.ModelKeyProvider;
    import com.sencha.gxt.data.shared.PropertyAccess;
    import com.sencha.gxt.widget.core.client.container.Viewport;
    import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
    import com.sencha.gxt.widget.core.client.grid.ColumnModel;
    import com.sencha.gxt.widget.core.client.grid.Grid;


    /**
    * Entry point classes define <code>onModuleLoad()</code>.
    */
    public class GXTSandBox implements EntryPoint
    {
    /**
    * This is the entry point method.
    */
    public void onModuleLoad ()
    {
    ListStore<Person> store = new ListStore<Person>(PersonProperties.INSTANCE.key());


    store.add(new Person("Abby"));
    store.add(new Person("Bart"));
    store.add(new Person("Clyde"));

    ColumnConfig<Person, String> nameColumn = new ColumnConfig<Person, String>(PersonProperties.INSTANCE.name());
    nameColumn.setHeader("Name");

    List<ColumnConfig<Person, ?>> columns = new ArrayList<ColumnConfig<Person, ?>>();
    columns.add(nameColumn);

    Grid<Person> grid = new Grid<Person>(store, new ColumnModel<Person>(columns));

    Viewport viewport = new Viewport();
    viewport.add(grid);

    RootPanel.get().add(viewport);


    }
    }


    /**
    *
    */
    class Person
    {
    /**
    */
    public interface PersonProperties extends PropertyAccess<Person>
    {
    /**
    */
    final PersonProperties INSTANCE = GWT.create(PersonProperties.class);


    /**
    *
    * @return ModelKeyProvider<Person>
    */
    @Path("name")
    ModelKeyProvider<Person> key();

    /**
    *
    * @return ValueProvider<Person, String>
    */
    ValueProvider<Person, String> name();
    }


    /**
    */
    private String name;



    /**
    * Constructor
    *
    * @param name String
    */
    public Person (String name)
    {
    this.setName(name);
    }


    /**
    *
    * @return String
    */
    public String getName ()
    {
    return this.name;
    }


    /**
    *
    * @param name String
    */
    public void setName (String name)
    {
    this.name = name;
    }
    }

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Thanks - this is indeed a missing piece of functionality, and while it does require an additional click from the user, it is still possible to achieve the same effect. I've filed this internally, and we'll post any updates or workarounds as they become available.

    That said, the functionality loss is not in the ListStore, but in the Grid/GridView. The ListStore is only responsible for sorting as instructed - as sorting is more flexible than in 2.x, it won't always be possible to display the sort behavior in grid headers. Instead, the Grid or GridView should have a way to tell it which sort to start with programmatically, to get the UI to update accordingly.

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    We've made a change in SVN that should fix this issue - if there is a sort object in the store that matches one of the existing columns, that column should now be decorated with the sort indicator. This fix is now in the latest nightly builds, and will be present in the next release.

Thread Participants: 1