FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse oCol:nHeadBmpNo Problem
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

xBrowse oCol:nHeadBmpNo Problem

Posted: Wed Jan 06, 2010 12:13 PM
Hi,

Is there anything specifically to be taken care of to display the Up and Down symbol displayed on the xBrowse Column Header using the oCol:nHeadBmpNo.

I am using the following function to Sort the RecordSet Data displayed on the xBrowse. The sorting is working fine, but it never displays the Up and Down arrow on the Header Column. I don't know where I am wrong.

Code (fw): Select all Collapse
oBrw:nHeaderHeight := 50   
oBrw:nHeaderLines  := 3  // No. of Lines Required on Header Column
oBrw:nFreeze       := 3  // Freeze columns till 3
AEval(oBrw:aCols,{|oCol|oCol:bLClickHeader:={|f,c,h,oCol|SortStkList(oBrw,oRecset,oCol)}})

*-------------------------------------------*
STATIC FUNCTION SortStkList(oBrw,oRs,oCol,cFld)
*-------------------------------------------*
   LOCAL cSort:=oRs:Sort,nLen,nFor
   DEFAULT cFld:=oCol:cHeader
   IF !Empty(oCol:cOrder)
      oCol:cOrder:=IF(oCol:cOrder=='ASC','DESC','ASC')
      oCol:nHeadBmpNo:=IF(oCol:cOrder=='ASC',1,2)
   ELSE
      nLen   := len( oBrw:aCols )
      for nFor := 1 to nLen
         oBrw:aCols[ nFor ]:nHeadBmpNo := 0
         oBrw:aCols[ nFor ]:cOrder := ""
      next
      oCol:cOrder:='ASC'
      oCol:nHeadBmpNo:=1
   ENDIF
   oRs:Sort:=cFld+Space(1)+oCol:cOrder
   oBrw:GoTop()
   MsgInfo(oCol:nHeadBmpNo)  // To see the Value of nHeadBmpNo
RETURN NIL


I tried using MsgInfo(oCol:nHeadBmpNo) and found that the value of oCol:nHeadBmpNo is changing perfectly ie either 1 or 2.

I am using Multiple line on Headers
oBrw:nHeaderLines := 3 // No. of Lines Required on Header Column

Any help ?

Regards
Anser
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse oCol:nHeadBmpNo Problem

Posted: Wed Jan 06, 2010 12:37 PM

First Point:

It is enough to assign oCol:cOrder := 'A' or 'D'.
You do not have to have any headerbmpno.
XBrowse automatically paints up arrow or down arrow ( built-in bitmaps) depending of whether oCol:cOrder is 'A' or 'D'.

Second Point:
If you are browsing a recordset, it is not necessary to code a detailed function for sorting.

It is enough to set oCol:cSortOrder := <SortColumnsList> and do not define any codeblock for header click. XBrowse automatically sorts ascending or descending when header is clicked.

Example: oCol:cSortOrder := 'DUE,DATE'
xBrowse takes care of appending ASC or DESC depending on the header click and displays built-in bitmaps.

Do you think you can not manage with the built-in sort ability of xBrowse?

Regards



G. N. Rao.

Hyderabad, India
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

Re: xBrowse oCol:nHeadBmpNo Problem

Posted: Thu Jan 07, 2010 04:28 AM
Dear Mr.Rao,

It is enough to assign oCol:cOrder := 'A' or 'D'.
You do not have to have any headerbmpno.
XBrowse automatically paints up arrow or down arrow ( built-in bitmaps) depending of whether oCol:cOrder is 'A' or 'D'.


You are right. I used oCol:cOrder := 'ASC' or 'DESC' instead of oCol:cOrder := 'A' or 'D', and that was the reason for the painting problem of the Up Arrow/Down Arrow bmp. So the correct usage is oCol:cOrder := 'A' or 'D

If you are browsing a recordset, it is not necessary to code a detailed function for sorting.
It is enough to set oCol:cSortOrder := <SortColumnsList> and do not define any codeblock for header click. XBrowse automatically sorts ascending or descending when header is clicked.


This is also working but the problem faced is that the first click on the Header activates the Sort on Descending order and the second click on the same column does not reverse the sort order ie Toggle option is not functioning. Do I have to code anything extra for this ie the fist click on the header should make the sort on that column in Ascending order and the second click on the header of the same column should sort in Descending order. The Function which I pasted on my previous post does that perfectly.
This is the code which I have used as per your advice.

Code (fw): Select all Collapse
oBrw:aCols[1]:cSortOrder:="Item_Code"
oBrw:aCols[2]:cSortOrder:="Item_Name"
oBrw:aCols[3]:cSortOrder:="Total"
for i:=1 to Len(aBranches)  // aBranches contains Column names of the Recordset
    oBrw:aCols[i+3]:cSortOrder:=aBranches[i]
Next


Any idea where I have gone wrong OR is this the expected default xBrowse behavior regarding oBrw:aCols[]:cSortOrder ?

Regards
Anser
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: xBrowse oCol:nHeadBmpNo Problem

Posted: Thu Jan 07, 2010 07:27 PM

Your syntax is right.

I just want to inform you that there is another way of userdefined sort. You can also assign a codeblock to cSortOrder. The codeblock does the actual sorting and returns 'A' or 'D'.

Behavior of XBrowse is if the column is unsorted, it sorts ascending and if it is already sorted, it toggles the sort.

Regards



G. N. Rao.

Hyderabad, India
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

Re: xBrowse oCol:nHeadBmpNo Problem

Posted: Fri Jan 08, 2010 07:51 AM
Behavior of XBrowse is if the column is unsorted, it sorts ascending and if it is already sorted, it toggles the sort.


I don't know where I have gone wrong.

Regards
Anser
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM

Re: xBrowse oCol:nHeadBmpNo Problem

Posted: Mon Feb 22, 2010 12:06 PM
Dear Mr.Rao,

Mr.Rao wrote:
Your syntax is right.

I just want to inform you that there is another way of user defined sort. You can also assign a codeblock to cSortOrder. The codeblock does the actual sorting and returns 'A' or 'D'.

Behavior of XBrowse is if the column is unsorted, it sorts ascending and if it is already sorted, it toggles the sort.


When I compiled my app using 10.1, Sort is working fine as per your suggested code.

Regards
Anser

Continue the discussion