Announcement

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

    Force $defaultOrderClause to use the FIELD name instead of tableName,nativeName pair

    Hi

    The server side sorting functionality in my listGrid is breaking mainly because I do not know how to force the defaultOrderClause to use the fieldName (the name attribute specified against my field definition in the ds.xml) instead of the tableName and nativeName attributes for that field.
    My query is something like this
    Code:
    SELECT * FROM(
    SELECT 
        S.STUD_NAME AS STUDNAME
    FROM
       STUDENT S
    WHERE
      S.STUD_NAME IN ('AAA','BBB')
    )
    ORDER BY STUDNAME
    my field is defined as
    <field name="STUDNAME" type="text" title="Student Name" tableName="S" nativeName="STUD_NAME"/>

    I use the defaultWhereClause with this field and get
    S.STUD_NAME IN ('AAA','BBB'). So my filtering works fine. But the sorting fails since it puts ORDER BY S.STUD_NAME. How do I get it to put ORDER BY STUDNAME instead.

    My actual query is much more complicated and I need to use the defaultWhereClause with the tableName,nativeName pair. My only worry is how do I force the orderWhereClause to take the fieldName instead of the tableName,nativeName pair

    #2
    What is wrong with simply defining an <orderClause> so you can control that part of the query?

    Comment


      #3
      We do not define an orderClause mainly to get the Listgrid to work properly with serverside sorting(when a user tries to sort on a field and the grid doesnt have all the data so it fires a query). If I do something like
      Code:
      <orderClause>
          STUDNAME
      </orderClause>
      It will always sort by STUDNAME. So when I try to do a server side sorting on the ListGrid, it will not dynamically put the appropriate field in the orderClause to get the output in the correct order. This is just a simple scenario. I have multiple fields in my listgrid similar to STUDNAME. If we try to sort on a specific field in the listgrid it puts the appropriate FIELD in the defaulOrderClause. When we use $defaultOrderClause, the orderClause is obtained from the tableName,nativeName pair defined for that field. Can we force it to take the name instead?
      We also do the following on the listgrid
      Code:
      setInitialSort(SortSpecifier);

      Is there any other approach I can adopt to achieve the same functionality and not break the sorting functionality on the listgrid?

      Comment


        #4
        Your order clause can include a Velocity conditional that causes it to only use your custom orderClause when you need it, and otherwise to use $defaultOrderClause.

        Or you could do the same thing from Java with dsRequest.addToTemplateContext().

        Comment


          #5
          Thanks for the replies. We are aware of these approaches but were curious on whether there was a property on a field that would enable us to force the orderWhereClause to take the fieldName instead of the tableName,nativeName pair. This would help us to write less in the ds.xml files

          So I understand that the defaultOrderClause and defaultWhereClause are similar in nature. And we cannot get the defaultOrderClause to work differently as compared to the defaultWhereClause.
          ie if the tableName,nativeName pair is used for the defaultWhereClause it will also be used for the defaultOrderClause.
          Am I right?

          Comment


            #6
            There isn't some kind of magic property that would cause your settings to function as documented everywhere except the order clause. Use <orderClause> to customize the order clause as previously indicated. The availability of $defaultOrderClause is documents in the QuickStart Guide and the further discussions in JavaDoc, which the QuickStart links to.

            Comment

            Working...
            X