We have datasource which pulls up the data from different tables and some calculated fields( some oracle functions)
<field name=“PY_NAME” title=“” type=“text” customSQL=“true” ></field>
$defaultSelectClause,GET_PY_NAME(PY_ID) AS PY_NAME
Our problem is we are not able to Sort and filter on PY_NAME from the grid
as this comes from the function and not associated with any table.(Complex calculated field)
Just as you’ve customized the <selectClause> you can go on and customize the <whereClause> as well.
If the criteria involved are optional (the client need not send them) you could use Velocity conditionals (#if - see Apache Velocity reference) to avoid outputting SQL that’s not needed.
Velocity “If” works only with Simple Criteria but not with the Advance Criteria
No, it works in both cases. See also the Custom Querying Overview and the $advancedCriteria variable.