Info window paging

- Fixed sorting bug

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2913975
This commit is contained in:
Heng Sin Low 2010-03-15 08:41:24 +00:00
parent a1942f8043
commit 4bf641e805
1 changed files with 41 additions and 1 deletions

View File

@ -1126,7 +1126,47 @@ public abstract class InfoPanel extends Window implements EventListener, WTableM
if (m_useDatabasePaging)
{
int col = lsc.getColumnIndex();
m_sqlUserOrder = " ORDER BY " + p_layout[col].getColSQL();
String colsql = p_layout[col].getColSQL().trim();
int lastSpaceIdx = colsql.lastIndexOf(" ");
if (lastSpaceIdx > 0)
{
String tmp = colsql.substring(0, lastSpaceIdx).trim();
char last = tmp.charAt(tmp.length() - 1);
if (tmp.toLowerCase().endsWith("as"))
{
colsql = colsql.substring(lastSpaceIdx).trim();
}
else if (!(last == '*' || last == '-' || last == '+' || last == '/' || last == '>' || last == '<' || last == '='))
{
tmp = colsql.substring(lastSpaceIdx).trim();
if (tmp.startsWith("\"") && tmp.endsWith("\""))
{
colsql = colsql.substring(lastSpaceIdx).trim();
}
else
{
boolean hasAlias = true;
for(int i = 0; i < tmp.length(); i++)
{
char c = tmp.charAt(i);
if (Character.isLetterOrDigit(c))
{
continue;
}
else
{
hasAlias = false;
break;
}
}
if (hasAlias)
{
colsql = colsql.substring(lastSpaceIdx).trim();
}
}
}
}
m_sqlUserOrder = " ORDER BY " + colsql;
if (!ascending)
m_sqlUserOrder += " DESC ";
executeQuery();