FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse: Process filtered rows only
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
xBrowse: Process filtered rows only
Posted: Mon Jun 01, 2020 07:59 AM
Hi Rao,
I have a 'Select All' checkbox. Right now it has this code attach to it
Code (fw): Select all Collapse
      oCbxAll:bChange := <||
                             aeval(oBrw:aArrayData, {|h_| h_["select"] := lAll})
                             oBrw:refresh()
                         >


But it has been pointed out to me this logic is not accurate if someone did filtering prior to checking it as it will traverse the whole array, not just filtered ones


As shown in the screen above which is displaying an array of hashes, when user clicks 'Select All' it is expected only the two visible rows should have the select flag toggled.
How should I code oCbxAll:bChange so it updates only filtered rows?

TIA
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: xBrowse: Process filtered rows only
Posted: Thu Jun 11, 2020 08:28 AM
I got an idea to do it this way. But seems to be caught in an infinite loop
Code (fw): Select all Collapse
    redefine checkbox oCbxAll var lAll id 109 of oDlg
      oCbxAll:bChange := <||
                              local hState := {=>}
                              hState["BookMark  "] := oBrw:BookMark
                              hState["nRowSel   "] := oBrw:nRowSel
                              hState["nColSel   "] := oBrw:nColSel
                              hState["nColOffset"] := oBrw:nColOffset
                              oBrw:gotop()
                              do while !oBrw:eof()
                                 h_ := oBrw:aRow()
                                 h_["select"] := lAll
                                 oBrw:goDown()
                              enddo
                              oBrw:BookMark   := hState["BookMark  "]
                              oBrw:nRowSel    := hState["nRowSel   "]
                              oBrw:nColSel    := hState["nColSel   "]
                              oBrw:nColOffset := hState["nColOffset"]
                              oBrw:refresh()
                         >
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: xBrowse: Process filtered rows only
Posted: Thu Jun 11, 2020 09:44 AM
Ok. This version seems to work
Code (fw): Select all Collapse
      oCbxAll:bChange := <||
                              local hState := {=>}
                              hState["BookMark  "] := oBrw:BookMark
                              oBrw:gotop()
                              REPEAT
                                 h_ := oBrw:aRow()
                                 h_["select"] := lAll
                              UNTIL oBrw:Skip( 1 ) != 1

                              oBrw:BookMark   := hState["BookMark  "]
                              oBrw:refresh()
                         >
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour

Continue the discussion