Hello
Xbrowse does not behave the same way with the autosort clause when browsing a dbf or an array
I explain , with dbf if we click on the header of the column, the sort is done and then the display will start on the same record as it was but sorted on that particular column. Bseek is issued automatically with autosort
In case of arrays , when clicking on the header of a column , the autosort is performed and we are positioned on the top of the array and this is a bad behaviour. seekonarray is not invoked in this case
Any idea how to correct this ?
Thanks for the help,
Richard
Fwh 10.10 but the problem is the same with fwh 11.01
Xbrowse array autosort behaviour
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Xbrowse array autosort behaviour
You are right. The current row should remain on the same row before sort.In case of arrays , when clicking on the header of a column , the autosort is performed and we are positioned on the top of the array and this is a bad behaviour.
Kindly apply this modification to xbrowse.prg.
Please locate the following line of code towards the end of METHOD SortArrayData() of TXBrwColumn:
Code: Select all
::oBrw:nArrayAt := AScan( ::oBrw:aArrayData, uSave )
Code: Select all
::oBrw:nArrayAt := AScan( ::oBrw:aArrayData, { |a| a == uSave } )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Re: Xbrowse array autosort behaviour
Mr Rao
Tested , the fix is correct.
Many thanks for your quick reply,
Best regards
Richard
Tested , the fix is correct.
Many thanks for your quick reply,
Best regards
Richard
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Re: Xbrowse array autosort behaviour
Richard , Nages :
Using Customer.dbf , index on FIELD->Last (column2 )
1) Ordering a dbf (using an index) and ordering a array (column) will not give the same results for equal fields when we look ar the recordnumber.
For 'Bink' we have 125 , 152 ,176 , 382 there is a subkey record number
In the array (first try ) : 152 , 176 ,382 , 125
second : 382 , 125 , 176 , 152
AT RANDOM !!!
2) When in the arraysort 'Bink' is searched to reset the browse , one from the 4 'Binks' is found (the first one in the ordered array)
This gives total wrong results when is clicked on a column as 'Married' (only .F. or .T.) . When the array is reset the first occurance from usave (.F. or .T.) is found , it has nothing to do with 'Bink" ! We have to combine this column with another to make it unique
Only with a subkey we can improve xbrowse . The results would be much better with a index on LAST + FIRST , but equal names (last+first) are still there . Search in 'Bink Gregory' gives one from the two.
For using subkeys with xbrowse see : http://forums.fivetechsupport.com/viewt ... =3&t=21153
Saving uSave and restoring it must be changed in MySetArray
Both problems can be solved with adding a column record number (or numbering the array)
In the DBF the indexexpression seems to be LAST + STR(RECNO()) , so in the array :
oBrw:aCols[2]:bOrder := {|a|TRIM(a[2])+STR(RECNO(),6)}
I will adapt the example in http://forums.fivetechsupport.com/viewt ... =3&t=21153 to have a working example
Frank
This key is unique . It would also be possible to save (usave) to the recnumber (sortarray)
I
Using Customer.dbf , index on FIELD->Last (column2 )
1) Ordering a dbf (using an index) and ordering a array (column) will not give the same results for equal fields when we look ar the recordnumber.
For 'Bink' we have 125 , 152 ,176 , 382 there is a subkey record number
In the array (first try ) : 152 , 176 ,382 , 125
second : 382 , 125 , 176 , 152
AT RANDOM !!!
2) When in the arraysort 'Bink' is searched to reset the browse , one from the 4 'Binks' is found (the first one in the ordered array)
This gives total wrong results when is clicked on a column as 'Married' (only .F. or .T.) . When the array is reset the first occurance from usave (.F. or .T.) is found , it has nothing to do with 'Bink" ! We have to combine this column with another to make it unique
Only with a subkey we can improve xbrowse . The results would be much better with a index on LAST + FIRST , but equal names (last+first) are still there . Search in 'Bink Gregory' gives one from the two.
For using subkeys with xbrowse see : http://forums.fivetechsupport.com/viewt ... =3&t=21153
Saving uSave and restoring it must be changed in MySetArray
Both problems can be solved with adding a column record number (or numbering the array)
In the DBF the indexexpression seems to be LAST + STR(RECNO()) , so in the array :
oBrw:aCols[2]:bOrder := {|a|TRIM(a[2])+STR(RECNO(),6)}
I will adapt the example in http://forums.fivetechsupport.com/viewt ... =3&t=21153 to have a working example
Frank
This key is unique . It would also be possible to save (usave) to the recnumber (sortarray)
I
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Xbrowse array autosort behaviour
No. uSave is not any value of any column. uSave is actually the pointer of the row array. So the same line will be shown after sort even if they are duplicate values.Saving uSave and restoring it must be changed in MySetArray
Well, about uniqueness and to retain the same key order in the database, the programmer has to bring in uniqueness in his ownway.
This can be achieved by adding a key column at the end and assigning it as oCol:cSortOrder.
Example:
We are reading an array of 3 columns from customer.dbf FIRST, LAST, CITY.
We can add FIRST + STR(RECNO()) AS 4th column.
Construct browse for 1,2 and 3rd columns only. ( 4th column is not visible). But set aCols[ 1 ]:cSortOrder := 4.
Then the first column is sorted in the order of 4th column.
In the above posting, if we want the FIRST to be sorted on FIRST-LAST, then we may add FIRST-LAST as the 4th column in the above example.
From 11.1 onwards even array seek is on 4th column.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Re: Xbrowse array autosort behaviour
Nages ,
I am using FWH 8.10 and tested :
1 ) Select BRINK (4 names) , Change between A and D several times , select item changes (between the for names)
2) click on married , no brinks more selected.
Sorry when it works now as expected
Frank
I am using FWH 8.10 and tested :
1 ) Select BRINK (4 names) , Change between A and D several times , select item changes (between the for names)
2) click on married , no brinks more selected.
Sorry when it works now as expected
Frank
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Xbrowse array autosort behaviour
Mr. Frank
There have been a lot of improvements to fwh and xbrowse over these years. I have seen the code you posted in the other post.
All that would not be needed now.
There have been a lot of improvements to fwh and xbrowse over these years. I have seen the code you posted in the other post.
All that would not be needed now.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
-
- Posts: 142
- Joined: Sun Oct 09, 2005 10:59 am
Re: Xbrowse array autosort behaviour
yes , i see now it is possible as described. Thank you very much for the explanation.nageswaragunupudi wrote:Mr. Frank
There have been a lot of improvements to fwh and xbrowse over these years. I have seen the code you posted in the other post.
All that would not be needed now.
Personally i am convinced that using ::bOrder in TXBrwColumn is a more elegant solution. In mine example i have to add 6 columns with your solution.
Also the filosofy from a dbf with a indexexpression is present in arraysort and seek in ::bOrder , we can use the same filosofy
And , very few changes are to be made in xbrowse.
Frank