How to make the Columns from SmartDB sorteable by clicking in it?

rolguin

Member
Hi,

I have added this code on the event START-SEARCH event of the SmartBrowser. I did that because I have the same code into another program which runs perfectly - ordering acend and descend for any column for the Browser.

What do I missing here?

DEFINE VARIABLE hCol AS HANDLE NO-UNDO.
DEFINE VARIABLE hSDO AS HANDLE NO-UNDO.

hCol = BROWSE {&browse-name}:CURRENT-COLUMN.
hSDO = DYNAMIC-FUNCTION("getDataSource").

IF DYNAMIC-FUNCTION("getQuerySort" IN hSDO) =
DYNAMIC-FUNCTION("columnDbColumn" IN hSDO,hCol:NAME) THEN
DYNAMIC-FUNCTION("setQuerySort" IN hSDO,
DYNAMIC-FUNCTION("columnDbColumn" IN hSDO,hCol:NAME) + " descending").
ELSE
DYNAMIC-FUNCTION("setQuerySort" IN hSDO,
DYNAMIC-FUNCTION("columnDbColumn" IN hSDO,hCol:NAME)).

DYNAMIC-FUNCTION("openQuery" IN hSDO).


Thanks in advance for any tip.


Kind regards,
rolguin
 

RealHeavyDude

Well-Known Member
You don't say anything about your Progress/OpenEdge version, and in particular not whether this is Dynamics or ADM2.

Why do you use the function "columnDBcolumn" in this code? As the SDB is strictly a visualization object it should only deal with fields in the RowObject Temp-Table and therefore the fields (columns) do not need to be qualified with a database or table name. Maybe that's the reason your code does not work. Although I have to admit that I did not do any tests I have no Dynamics/ADM2 development environment at hand at the moment.

From my experience I would suggest that a call to "setQuerySort" should be sufficient, passing it just the name of the column that you've retrieved.


Heavy Regards, RealHeavyDude.
 
Hi

Assuming that the object for the browse is called br_table (Using ADM2 to link all the objects on a Smart Window) then in
Definitions section

DEF VAR lastcol AS HANDLE NO-UNDO.
DEF VAR tmpdesc AS CHAR NO-UNDO.
DEF VAR datasource AS HANDLE.
DEF VAR csort AS CHAR NO-UNDO.
DEF VAR tmpcol AS HANDLE NO-UNDO.
DEF VAR hdatasource AS HANDLE NO-UNDO.

and in the START-SEARCH Trigger

tmpcol = br_table:CURRENT-COLUMN.
IF lastcol = tmpcol THEN DO:
IF tmpdesc = "" THEN
tmpdesc = " DESC ".
ELSE tmpdesc = "".
END. /*lastcol = tmpcol*/
ELSE tmpdesc = "".
ASSIGN
lastcol = tmpcol
csort = tmpcol:NAME + tmpdesc .

datasource = DYNAMIC-FUNCTION('getDataSource':U).
{set querySort csort dataSource}.
{fn openQuery dataSource}.


I hope that helps
Mike
 
Top