Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid Sorting with SQL Datasource/Templating

    SmartGWT Power 2.4 / Firefox

    Hi. I'm using SQL templating to pull SQL Server into a listgrid. All's well gathering data except for sorting (initial and additional fetches/filters). What is the correct way to configure sorting? I've tried:

    1. (in ds.xml) order clause (<orderClause>>COLUMN_NAME) DESC</orderClause>)

    2. (in listgrid) setSortField(COLUMN_NAME)

    3. (in listgrid) setInitialSort(SortSpecifier)

    3. (in listgrid) setSort(SortSpecifier)

    5. I've also tried defining the ListGridField with type INTEGER to ensure it was not interpreted as a string (there was another thread on that). It's a currency value, but I removed the cell formatter to see if formatting was causing the problem, its' not. Even as an integer, it does not sort.

    When using the <orderClause> the generated SQL 'ORDER BY' clause is correct:

    ORDER BY revenue DESC

    ...and then when executing that generated SQL in SQL Server, the results are sorted corrected, so the SQL is correct and generates correct results. It's not sorted correctly in the ListGrid.

    What am I doing wrong?

    Thanks in advance.

    #2
    Use clause by clause customization of SQL rather than replacing the whole query ( <customSQL> ). That way the SQL for sorting is still generated for you.

    Comment


      #3
      Thanks, but I'm still not successful. Here's my operationBinding (removed part of select for brevity):
      Code:
      <operationBinding operationType="fetch">
          <selectClause>
              MAX(sfp.sId) AS sId, 
              MAX(sfp.sName) AS sName, 
              COUNT(1) AS total,
              SUM(CASE WHEN lc.rStatus = 'complete' THEN 1 ELSE 0 END) AS complete,
              SUM(lc.cents) AS valueCents, 
              ....
              MAX(dt.createdAt) AS createdAt
          </selectClause>
          <tableClause>
               schema.db.table lc
               INNER JOIN schema.db.table2 sfp ON lc.id = sfp.id
          </tableClause>
          <whereClause>$defaultWhereClause</whereClause>
          <groupClause>sfp.sName</groupClause>
          <orderClause>valueCents DESC</orderClause>
      </operationBinding>

      Comment


        #4
        If you look in the Developer Console in the RPC Tab, are the results sorted?

        If so, maybe the client-side sort results are not the same. Try disabling useClientSorting via ListGrid.setDataProperties()

        Comment

        Working...
        X