Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Sorting grids
Tue, Oct 31 2017 7:00 AMPermanent Link

Matthew Jones

Hmm, sort of stuck in sorting. I am struggling to work out how to allow dates to sort nicely in the grid.

I have a grid, filled manually with AppendRow. It contains text, numbers and dates. I found that clicking on the column headers for sorting was not too good - all done using text comparison. Fixing the numerics was relatively easy by attaching a sort function and converting the strings to numbers and comparing.

However, dates are sort of more complicated because I have a "friendly" display. Even if I take that out, I have to convert dates from strings to dates each time. It would be a lot nicer if I could get the index into the main data list and handle the data directly, but the sort function is only passed the strings. I figured I could pass in a more raw date and display it nicely in the grid, but that isn't possible as the update function is cell attributes only.

I shall revert to processing my strings and making dates, but in a grid of 8000 items, that is a lot of duplication needed.

Maybe I'm missing something, like a virtual grid, so if so, please tell me what to look for...

--

Matthew Jones
Tue, Oct 31 2017 7:33 AMPermanent Link

Mark Brooks

Slikware

Avatar

Disclaimer - I have never used EWB grids .............

However, could you use a hidden column, that holds the DateTime (integer) date value and sort on that?
Tue, Oct 31 2017 9:17 AMPermanent Link

Matthew Jones

Mark Brooks wrote:

> However, could you use a hidden column, that holds the DateTime (integer) date value and sort on that?

No, because the sort function is literally passed two strings and has no other context.

I'm not expecting any big change any time soon, but bringing it up will help Tim make the right decisions down the line as he makes improvements. (I hope, but most times he's already ahead of my needs.)

--

Matthew Jones
Tue, Oct 31 2017 1:44 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Hmm, sort of stuck in sorting. I am struggling to work out how to allow dates to sort nicely in the grid. >>

Data-bound, or not ?  If the grid isn't data-bound, then there isn't any other option than to sort strings because that is what is stored in an unbound grid.

If the grid is bound, then the date/times are already being sorted in a binary fashion.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Nov 1 2017 5:28 AMPermanent Link

Matthew Jones

Tim Young [Elevate Software] wrote:

> If the grid is bound, then the date/times are already being sorted in a binary fashion.

Hmm, therein lies my trouble - it is not bound. The problem I have is that I need to filter rapidly, and am not aware of this as a feature of the data storage. So take a data set with 8,000 entries, find all with "fred" in and just show those. Also to be able to alter the text from the dataset to a varation for display.

--

Matthew Jones
Wed, Nov 1 2017 11:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Hmm, therein lies my trouble - it is not bound. The problem I have is that I need to filter rapidly, and am not aware of this as a feature of the data storage. So take a data set with 8,000 entries, find all with "fred" in and just show those. Also to be able to alter the text from the dataset to a varation for display. >>

I'll be modifying this, once the component library updates resume after 2.07.  The non-bound grid should have just used a temporary dataset and allowed for proper types, but I wanted to make it behave more like Delphi's string grid, so....

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Nov 1 2017 12:02 PMPermanent Link

Mark Brooks

Slikware

Avatar

So, surely, a hidden column with the datetime value will work, albeit formatted as a left-zero-padded string. Or should I "get my coat" now?
Wed, Nov 1 2017 12:56 PMPermanent Link

Matthew Jones

Mark Brooks wrote:

> a hidden column with the datetime value will work,

Any sort of reference to the index would help, but there isn't one. Just two strings passed in. Without more context, or the ability to change the display value independently from the stored data, there is nothing that can be done.

--

Matthew Jones
Image