You may want to look into this. It was just reported to me this morning. I don't know when it broke, but assume it was in upgrading smartgwt versions. The commented out sort specifier used to work. Now I need to reference the includefile name, rather then the field name.
//testCommentViewGrid.setSortField("Session_Create_Time"); // Calling out the field name broke somewhere
testCommentViewGrid.setSortField("Test_Session.Ct_on_Create");
testCommentViewGrid.setSortDirection(SortDirection.DESCENDING);
DataSource ds.xml file:
<DataSource ID="TestCommentView" serverType="sql" tableName="Test_Status">
<fields>
<field name="PK_Test_Status" title="*" type="sequence" width="20" align="center" cellAlign="center" primaryKey ="true" prompt="* indicates that this comment is for the current test" cellFormatterrrrrrr="" />
<field name="FK_Test_Suite" title="FK_Test_Suite" type="integer" width="100" hidden="true" foreignKey="Test_Suite.PK_Test_Suite"/>
<field name="FK_Test_Record" title="PK_Test_Record" type="integer" width="100" detail="true" />
<field includeFrom="Test_Session.SessionID" />"
<field name="Session_Create_Time" nativeName="CT_on_Create" includeFrom="Test_Session.CT_on_Create" detail="true" align="center" cellAlign="center" sortDirection="descending" dateDisplayFormatter="TOEUROPEANSHORTDATETIME" />
<field name="Comment" title="Test Comment History" type="text" width="*" length="1023" editorType="com.smartgwt.client.widgets.form.fields.RichTextItem" />
</fields>
</DataSource>
The generated SQL for the field name version of the sort omits it in the order by clause:
=== 2019-09-10 13:21:01,103 [-585] DEBUG SQLDataSource - Using SQL Limit query
=== 2019-09-10 13:21:01,103 [-585] WARN SQLOrderClause - DataSource 'TestCommentView': Attempting to sort by field 'Session_Create_Time', but found no native column for the field. Ignoring.
=== 2019-09-10 13:21:01,104 [-585] DEBUG SQLDataSource - SQL windowed select rows 0->75, result size 75. Query:
SELECT
*
FROM
(SELECT
*,
ROW_NUMBER() OVER (
ORDER BY
-- Nothing exists here. It should contain Test_Session.CT_on_Create field
) AS rowID
FROM
(SELECT
TOP 100 PERCENT Test_Status.PK_Test_Status,
Test_Status.FK_Test_Suite,
Test_Status.FK_Test_Record,
Test_Status.Comment,
Test_Session.SessionID
FROM
Test_Status
JOIN
Test_Suite
ON Test_Status.FK_Test_Suite = Test_Suite.PK_Test_Suite
JOIN
Test_Session
ON Test_Suite.FK_Test_Session = Test_Session.PK_Test_Session
WHERE
(
(
Test_Status.FK_Test_Record = 33856
AND Test_Status.FK_Test_Record IS NOT NULL
)
)) x) y
WHERE
y.rowID BETWEEN 1 AND 75
//testCommentViewGrid.setSortField("Session_Create_Time"); // Calling out the field name broke somewhere
testCommentViewGrid.setSortField("Test_Session.Ct_on_Create");
testCommentViewGrid.setSortDirection(SortDirection.DESCENDING);
DataSource ds.xml file:
<DataSource ID="TestCommentView" serverType="sql" tableName="Test_Status">
<fields>
<field name="PK_Test_Status" title="*" type="sequence" width="20" align="center" cellAlign="center" primaryKey ="true" prompt="* indicates that this comment is for the current test" cellFormatterrrrrrr="" />
<field name="FK_Test_Suite" title="FK_Test_Suite" type="integer" width="100" hidden="true" foreignKey="Test_Suite.PK_Test_Suite"/>
<field name="FK_Test_Record" title="PK_Test_Record" type="integer" width="100" detail="true" />
<field includeFrom="Test_Session.SessionID" />"
<field name="Session_Create_Time" nativeName="CT_on_Create" includeFrom="Test_Session.CT_on_Create" detail="true" align="center" cellAlign="center" sortDirection="descending" dateDisplayFormatter="TOEUROPEANSHORTDATETIME" />
<field name="Comment" title="Test Comment History" type="text" width="*" length="1023" editorType="com.smartgwt.client.widgets.form.fields.RichTextItem" />
</fields>
</DataSource>
The generated SQL for the field name version of the sort omits it in the order by clause:
=== 2019-09-10 13:21:01,103 [-585] DEBUG SQLDataSource - Using SQL Limit query
=== 2019-09-10 13:21:01,103 [-585] WARN SQLOrderClause - DataSource 'TestCommentView': Attempting to sort by field 'Session_Create_Time', but found no native column for the field. Ignoring.
=== 2019-09-10 13:21:01,104 [-585] DEBUG SQLDataSource - SQL windowed select rows 0->75, result size 75. Query:
SELECT
*
FROM
(SELECT
*,
ROW_NUMBER() OVER (
ORDER BY
-- Nothing exists here. It should contain Test_Session.CT_on_Create field
) AS rowID
FROM
(SELECT
TOP 100 PERCENT Test_Status.PK_Test_Status,
Test_Status.FK_Test_Suite,
Test_Status.FK_Test_Record,
Test_Status.Comment,
Test_Session.SessionID
FROM
Test_Status
JOIN
Test_Suite
ON Test_Status.FK_Test_Suite = Test_Suite.PK_Test_Suite
JOIN
Test_Session
ON Test_Suite.FK_Test_Session = Test_Session.PK_Test_Session
WHERE
(
(
Test_Status.FK_Test_Record = 33856
AND Test_Status.FK_Test_Record IS NOT NULL
)
)) x) y
WHERE
y.rowID BETWEEN 1 AND 75
Comment