[Gambas-user] Sorting gridviews

B Bruen bbruen at ...2308...
Sat Jul 5 23:49:58 CEST 2014


Hi Tobi,

I too have implemented a similar approach to yours, but it is not what I was looking for.  I am trying to implement a sort over multiple columns, like "ORDER BY ColA ASC, ColC DESC, ColB ASC" in an sql query.  I just cannot get it right.  In fact, I have now decided that the easiest way is to create a temporary Sqllite db, fill it with the columns of the array and let it do the sorting.  Not an optimal solution but at least it works for the data sets we will be using it for.

regards
Bruce

On Wed, 25 Jun 2014 13:51:42 +0200
Tobias Boege <taboege at ...626...> wrote:

> On Wed, 25 Jun 2014, B Bruen wrote:
> > Someone, recently, was discussing sorting gridviews over multiple columns. Tobi?
> > 
> > Was any progress made on this?
> > 
> 
> The project was finished some time ago. But likely the results will not
> please you because the code is not very integrative.
> 
> Basically, we model the GridView as an array of Record objects (the array is
> the rows, a Record describes the columns in the GridView). By a special
> RecordArray class which Inherits Record[] and a special _compare() method in
> Record, we can sort that RecordArray by any property of the Record objects.
> 
> So you must write a Record class for your specific purpose and have an array
> of them behind the scenes to populate the GridView with. Maybe you can tweak
> the code to be a bit more general... if you get it much more general, please
> tell me :-) [ IIRC, we have a SortField property in each Record object which
> we need to set for each object in the array before we sort. I think you can
> replace that with a static property if you never sort multiple arrays at the
> same time... ]
> 
> The code for the GridView is here[0] and also here[1] in the more abstract
> context of sorting multidimensional arrays. (The project archives are at the
> end of the article.)
> 
> Regards,
> Tobi
> 
> [0] http://www.gambas-buch.de/dw/doku.php?id=k17:k17.7:k17.7.4:start
> [1] http://www.gambas-buch.de/dw/doku.php?id=k7:k7.4:k7.4.9:k7.4.9.4:start
> 
> PS: I would prefer [1] over [0]. The code used in [0] was actually an early
> try from me and it uses the officially not supported possibility to override
> Variant[]. (Variant[] acts as both, a Record object and also as an array
> class for Variant[] objects there!)
> 
> -- 
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
> 
> ------------------------------------------------------------------------------
> Open source business process management suite built on Java and Eclipse
> Turn processes into business applications with Bonita BPM Community Edition
> Quickly connect people, data, and systems into organized workflows
> Winner of BOSSIE, CODIE, OW2 and Gartner awards
> http://p.sf.net/sfu/Bonitasoft
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user


-- 
B Bruen <bbruen at ...2308...>




More information about the User mailing list