Clearing DataSet.IndexFieldNames without restoring original order?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Thu 25 Feb 2016 03:32

In build 9.5.16 the IndexFieldNames behavior when clearing the property was changed to revert to the original sort order. In prior builds setting IndexFieldNames and then clearing it caused the dataset to retain its last set sort order but to no longer be actively sorted. This was actually useful when editing in a grid as the user could choose to sort the dataset, and then edit it without records moving around (jumping to their actively sorted position) as they were changed (or inserted). Is it possible to clear IndexFieldNames and retain the current order? Alternately, is there some other way to sort a dataset and then set the dataset so that changed records aren't actively sorted? I hope this question is clear but I'll be happy to clarify if it is not. Thank you for any suggestions.

-Mark Ford
Benthic Software

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Fri 26 Feb 2016 10:42

Hello,

No, the behavior you expect is incorrect. On any change of IndexFieldNames (even on setting an empty value) the dataset must be sorted again, and the cursor must remain on the current record.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Fri 26 Feb 2016 12:38

Although you may consider it incorrect, the behavior was like that for years and years. With the new behavior it isn't possible to sort a dataset before editing it in a grid (imagine what happens when you paste a block of data into a grid that is being actively sorted during the paste.) So imagine the scenario:

User runs a query.
User clicks a grid column to sort the dataset (let's say by date.)
User decides to edit the data in a datagrid by pasting in a block of data.
(at this point we must clear IndexFieldNames or the records will try to actively sort during editing.)
Suddenly the data goes back to the original sort order, instead of the old behavior of retaining the sort.

This is a big lost feature! I now have to explain to users that they can no longer change the sort order of a dataset before editing it.

I can imagine that being able to return to the original sort order is a nice feature, but there should be a different way to do it (i.e. a function called "RevertSortOrder" or a special value that IndexFieldNames can be set to such as "REVERT")

Alternately we need a new property that sorts the dataset without turning "active sorting" on (this was always achieved by setting IndexFieldNames and then clearing it.) A new properly called "SortByFieldNames" with the same syntax handling as the current IndexFieldNames would be perfect.

If it's truely the case that the old behavior was a bug, please (with a capital P) consider a new sorting feature that gives us back this ability!

-Mark Ford
Benthic Software

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Fri 26 Feb 2016 13:57

All data access components behave in the same way (you can make this sure using the standard components - FireDAC). We have modified this behavior due to user requests.
The way you are suggesting is rather strange behavior. Because when modifying data, it will be displayed incorrectly taking into account the filter

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Fri 26 Feb 2016 15:06

Well, regardless of that, I've relied on this behavior for years. Your comment about "Because when modifying data, it will be displayed incorrectly taking into account the filter" is a misunderstanding of the issue. An active "filter" (I call it "Active sorting") needs to be turned off in any case for grid style editing. Unfortunately now it means that the data reverts to the original sort order instead of maintaining the sort. Basically I used the "feature" as a way to turn active sorting off and yet maintain the current sort order. Regardless of whether the previous behavior was a bug, the loss of this ability is a real problem (and I'm going to catch a lot of complaints over it.)

So assuming that you don't agree with the above (for whatever reason), how about adding the ability to turn active sorting off? It seems like this ability would be very useful. Or add a sort feature that just sorts the dataset but does not turn "Active sorting" on. This feature would solve this problem nicely (and perhaps it's easy to implement since it always worked that way before.)

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Tue 01 Mar 2016 19:02

The FireDAC documentation
http://docwiki.embarcadero.com/RADStudi ... FireDAC%29
states:

To sort dataset by original records order (as the records were fetched and /or appended), use '#' as a value for IndexFieldNames and Fields properties.

If that's correct, how about matching their convention? That would seem to be the best of both worlds (allowing a return to the original sort order while also allowing us to maintain the current sort order while turning "active sorting" off.)

-Mark Ford
Benthic Software

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Fri 04 Mar 2016 11:35

In our products, to return sorting to the initial level (as returned by the database), you should just clear IndexFieldNames.
If you want us to implement any feature, you can leave a suggestion to extend functionality at our uservoice forum: https://devart.uservoice.com/forums/104 ... components .

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Fri 04 Mar 2016 13:19

Well obviously that's a very disappointing answer after I've spent so much time explaining the issue. So there's no longer a way to turn off active sorting without reverting the dataset to the original sort order... even though ODAC has allowed this for years... great.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Fri 18 Mar 2016 13:43

If you have a source version, we can tell you where to change the code to get the old incorrect behavior.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by MarkF » Fri 18 Mar 2016 19:34

Thank you, I've already done so. This would make a nice option I'd think (and very easy to implement.)

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Thu 21 Apr 2016 04:02

We will consider the possibility to add such option in one of the next versions.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by Ludek » Tue 24 Jan 2017 07:59

Hi, is such version already available? (I need it in SDAC)
Or, at least, would you mind publishing the needed change in sources?
Thanks, Ludek.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Tue 24 Jan 2017 11:04

To restore the old behavior you need in the MemData module to change the TMemData.SortItems method as follows:

from the condition

Code: Select all

if  (IndexFieldsCount = 0) and not FOrderSaved then
delete the check

Code: Select all

and not FOrderSaved

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by Ludek » Tue 24 Jan 2017 15:31

Thank you very much, I'll try!
Ludek.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Clearing DataSet.IndexFieldNames without restoring original order?

Post by AlexP » Wed 25 Jan 2017 08:25

If you have any other questions, feel free to contact us

Post Reply