When I call ListGrid.sort (), the ListGrid is not sorted.
I noticed this in the following cases:
1. The sortField is part of the ListGridRecord, but not added as a ListGridField to the ListGrid, or
2. The sortField is part of the ListGridRecord, and added as a ListGridField to the ListGrid, but hidden
Sorting seems to work ONLY if the field is displayed on the screen.
Additionally, when sorting does not work, it seems that the ListGrid is sorted by the first visible column.
See the attached picture for an example.
This is the ListGrid method I am calling:
Using
SmartGWT 3.0
GWT 2.3.0
Firefox 6.0.2
Is this by design?
Should I open a bug?
Any advice on how to get this to work?
I noticed this in the following cases:
1. The sortField is part of the ListGridRecord, but not added as a ListGridField to the ListGrid, or
2. The sortField is part of the ListGridRecord, and added as a ListGridField to the ListGrid, but hidden
Sorting seems to work ONLY if the field is displayed on the screen.
Additionally, when sorting does not work, it seems that the ListGrid is sorted by the first visible column.
See the attached picture for an example.
This is the ListGrid method I am calling:
Code:
public native Boolean sort(String sortField, SortDirection sortDirection)
SmartGWT 3.0
GWT 2.3.0
Firefox 6.0.2
Code:
import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.types.Autofit; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.types.GroupStartOpen; import com.smartgwt.client.types.SortDirection; import com.google.gwt.core.client.EntryPoint; public class TestListGridSort implements EntryPoint { /** * The EntryPoint interface */ public void onModuleLoad () { // create ListGrid final ListGrid listGrid = new ListGrid (); listGrid.setShowAllRecords (false); listGrid.setAutoFetchData (false); listGrid.setCanEdit (false); listGrid.setAutoFitData (Autofit.BOTH); listGrid.setCanSort (true); listGrid.setSelectionType (SelectionStyle.SINGLE); // allow only single-selection // by default, group by Today/Yesterday/Before Yesterday listGrid.setGroupStartOpen (GroupStartOpen.ALL); listGrid.setCanGroupBy (true); listGrid.setGroupByField ("group"); // add fields final ListGridField groupField = new ListGridField ("group", "Group", 100); final ListGridField displayIndexField = new ListGridField ("displayIndex", "Display Index", 50); final ListGridField nameField = new ListGridField ("name", "Name", 150); listGrid.setFields ( groupField, displayIndexField, nameField); // hide management columns // WARNING: if listGrid.hideField ("displayIndex"); is called, the sort () invocation below appears to do nothing listGrid.hideField ("group"); listGrid.hideField ("displayIndex"); // add records { final ListGridRecord listGridRecord = new ListGridRecord (); listGridRecord.setAttribute ("group", "Group One"); listGridRecord.setAttribute ("displayIndex", 400); listGridRecord.setAttribute ("name", "Name 1"); listGrid.addData (listGridRecord); } { final ListGridRecord listGridRecord = new ListGridRecord (); listGridRecord.setAttribute ("group", "Group Two"); listGridRecord.setAttribute ("displayIndex", 200); listGridRecord.setAttribute ("name", "Name 3"); listGrid.addData (listGridRecord); } { final ListGridRecord listGridRecord = new ListGridRecord (); listGridRecord.setAttribute ("group", "Group One"); listGridRecord.setAttribute ("displayIndex", 300); listGridRecord.setAttribute ("name", "Name 2"); listGrid.addData (listGridRecord); } { final ListGridRecord listGridRecord = new ListGridRecord (); listGridRecord.setAttribute ("group", "Group Two"); listGridRecord.setAttribute ("displayIndex", 100); listGridRecord.setAttribute ("name", "Name 4"); listGrid.addData (listGridRecord); } // sort by name listGrid.sort ("displayIndex", SortDirection.ASCENDING); // add a button -- maybe sorting works after the ListGrid is displayed final IButton button = new IButton (); button.setTitle ("Sort by displayIndex"); button.addClickHandler (new ClickHandler () { public void onClick (ClickEvent event) { listGrid.sort ("displayIndex", SortDirection.ASCENDING); } }); // layout final VLayout layout = new VLayout (); layout.addMember (listGrid); layout.addMember (button); layout.show (); } }
Should I open a bug?
Any advice on how to get this to work?
Comment