TK's KControls Suite - KGrid number sorting bug lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- JD · 2009-10-16 07:40 Hello TK, Congratulations for a wonderful job done with the release of the Kcontrols suite 1.0. I use Lazarus as my development tool & it will be very useful to me. I've used it in my project but I notice that the KGrid sorting has a bug when it is sorting numbers. I seems to treat them as text. I attach two screenshots of my work. I created a stored procedure to fetch the rows & then filled a stringgrid and then a KGrid with the results. Initially both grids are properly sorted because they contain the unaltered sort order passed by the stored procedure (see kgrid before sorting.png) but once I click on the KGrid number column to change the sort order, I get what you see in (kgrid after sorting.png). You will immediately notice that in the KGrid, 8 comes before 75, 7 comes before 67 and so on. What do I do to correct the KGrid number sorting bug? In addition, I also have some stored procedures with date rows and decimal rows. I haven't tested KGrid with these stored procedures rows but does it properly sort on date rows and decimal rows? Regards, JD ---------------------------------------------------------------------- cpalx · 2009-10-16 12:28 how did you do left panel??? ---------------------------------------------------------------------- JD · 2009-10-16 14:19 Quote from: cpalx on October 16, 2009, 02:28:30 pmhow did you do left panel??? The left panel is the JvXPBar - a Lazarus port of the JVCL suite. You'll find it here http://wiki.lazarus.freepascal.org/JvXPBar The clock at the bottom is a component in the RxLib suite. You'll find it here http://wiki.lazarus.freepascal.org/RXfpc JD ---------------------------------------------------------------------- tk · 2009-10-16 19:50 Hi JD, i've sent you an email but not sure you've receive it. Now I discovered this post, so I reply here too (maybe it could interest others). If you wish to sort integers or any other non-string data in tkgrid you have to adapt the OnCompareCells event. You can use e.g. the CompareIntegers function from KFunctions or make your own in similar way for dates etc. With this approach you can sort anything (except multilevel/tree sorting which I haven't implemented yet). A combination of sorting a text and integer next to the text is shown in the main demo (I agree the main demo is little bit huge, for newbies especially but it shows how many features can be combined together). In next version I consider more column properties anyway so I might introduce a property to tell how to sort rows in a column by default. If sorting a database data in a kdbgrid, you need a different approach - adapt the OnCustomSortRows event as shown in the kdbgrid demo. I didn't publish kcontrols here intentionally as the printing works only for win32 now. I'm implementing the missing functions for Lazarus now. I hope I'll submit my patch to the Lazarus developers soon. Then I make an announcement (with some hint for users who wish to use the printing e.g. in Linux). Tomas ---------------------------------------------------------------------- JD · 2009-10-17 08:28 Quote from: tk on October 16, 2009, 09:50:49 pmHi JD, i've sent you an email but not sure you've receive it. Now I discovered this post, so I reply here too (maybe it could interest others). I got the email but was unable to reply quickly. I'll keep you posted on the results of your tips. Thanks, JD