is there any way to set dataset/data-source to sort?

Posted by mhtan88 on 09-Nov-2009 03:45

hi all,

is there any way to simulate like fill-where-string( not setable in OpenEdge10.0B)?

because the dataset dstable:fill() will base on temp-table 's "default" index sort.

Thank you.

Regards,

TanMH

All Replies

Posted by jquerijero on 09-Nov-2009 08:56

You use DataView for the pupose of re-querying the dataset. The other option is to use the DataTable:Select() which returns an array of DataRows. Both of this implementations use a SQL like syntax.

Posted by mhtan88 on 09-Nov-2009 09:54

Thank you joseph,

but i'm doing manual data batch control and also manual paging in gridview due to huge dataset in c# is not a good idea.  Therefore, I can't use the dataset return to the .Net and redo the sorting at .Net. And i force to do the sorting nicely at prodataset 4GL and return right rows to gridview. is there any idea?

I believe fill-where-string can may solve my problem. but i'm using 10.0B 05.  fill-where-string is not setable.

Thank you.

Regards,

TanMH

Posted by jquerijero on 09-Nov-2009 10:43

I believe you can just re-assign a new query to the ProgressBindingSource and re-open it.

Posted by Håvard Danielsen on 09-Nov-2009 12:29

You are right that batching with sorting requires that you apply sort critieria to the query used to fill data.

You can do this by creating a standard ABL query (myquery) with the sort criteria and then set mydatasource:query = myquery.  This is often a better approach in more advanced cases anyways, as you cannot use fill-where-string when the query has more than one table.

Posted by mhtan88 on 09-Nov-2009 17:26

hi Havard,

Can you show me some sample coding in 4GL?  This is my first time using this prodataset.

Thank you.

Regards,

TanMH

Posted by Håvard Danielsen on 11-Nov-2009 07:19

This snippet from your code (from another posting) is already preparing the query for your data-source.

Just add the sort criteria to pc_query. I.e. "for each 

no-lock by indexed-reposition"

QUERY qBank:QUERY-PREPARE(pc_query).
DEFINE DATA-SOURCE srcbank FOR QUERY qBank.

Keep in mind that the sort of the data-source only affects the fill of the temp-table. You need to apply a similar sort whenever you traverse or browse the temp-table for this to make any sense. If your sort criteria is not unique the sort of the temp-table may still be in a different order than the fill order. This can give very confusing results on the client when batching, as the new batch may not be appended at the end. One really need to ensure that sort criteria are unique in order to support batching and sorting (for example by applying the key at the end of the sort).

Message was edited by: Havard Danielsen

Posted by mhtan88 on 11-Nov-2009 08:35

thank you very much!!!!

This thread is closed