I'm using SmartGWT 2.4 trying to set the initial sort direction for a particular column in a list grid.
The javadoc for the setSortDirection() method in ListGridField says:
Specifies the default sorting direction for this column. If specified on the sortField for the listGrid, sorting occurs automatically, otherwise this will be the default direction when the user clicks the field header, or calls ListGrid.sort() without specifying an explicit sort direction.
That is exactly what I want - I have a numeric column that I would like to sort descending when the user clicks on the header for the first time. But calling that method for that field doesn't seem to have any effect - the column is still sorted in ascending order when I click on it.
Here is my simple test program that illustrates this problem:
I have looked over the ShowCase Grid Sort example at http://www.smartclient.com/smartgwt/showcase/#grid_sort_sort
It seems to work in that example - I don't why it works there but not in my sample application.
This thread http://forums.smartclient.com/showthread.php?t=12493&highlight=setSortDirection describes the same problem - but the workaround "fix" described there doesn't even compile for me.
The javadoc for the setSortDirection() method in ListGridField says:
Specifies the default sorting direction for this column. If specified on the sortField for the listGrid, sorting occurs automatically, otherwise this will be the default direction when the user clicks the field header, or calls ListGrid.sort() without specifying an explicit sort direction.
That is exactly what I want - I have a numeric column that I would like to sort descending when the user clicks on the header for the first time. But calling that method for that field doesn't seem to have any effect - the column is still sorted in ascending order when I click on it.
Here is my simple test program that illustrates this problem:
Code:
private static final String SALARY = "Salary"; private static final String JOB = "Job"; private static final String NAME = "Name"; public void onModuleLoad() { final ListGrid listGrid = new ListGrid(); listGrid.setWidth(500); listGrid.setHeight(400); ListGridField nameField = new ListGridField(NAME, 150); ListGridField jobField = new ListGridField(JOB, 150); ListGridField salaryField = new ListGridField(SALARY); salaryField.setType(ListGridFieldType.INTEGER); salaryField.setSortDirection(SortDirection.DESCENDING); listGrid.setFields(nameField, jobField, salaryField); listGrid.setData(getData()); listGrid.draw(); } private ListGridRecord[] getData() { ListGridRecord[] records = new ListGridRecord[] { makeRecord("Charles Madigen", "CEO", 26200), makeRecord("Joan Little", "Mgr", 19600), makeRecord("Kirel Amirov", "Tech Mgr", 19500), makeRecord("Tammy Plant", "Secretary", 18800), makeRecord("Glenda Witch", "Worker", 15000), makeRecord("Pat Freel", "Clerk", 12000), makeRecord("Brenda Cox", "Owner", 45000) }; return records; } private ListGridRecord makeRecord(String name, String job, int salary) { ListGridRecord record = new ListGridRecord(); record.setAttribute(NAME, name); record.setAttribute(JOB, job); record.setAttribute(SALARY, salary); return record; }
It seems to work in that example - I don't why it works there but not in my sample application.
This thread http://forums.smartclient.com/showthread.php?t=12493&highlight=setSortDirection describes the same problem - but the workaround "fix" described there doesn't even compile for me.
Comment