xBrowse: Process filtered rows only

xBrowse: Process filtered rows only

Postby hua » Mon Jun 01, 2020 7:59 am

Hi Rao,
I have a 'Select All' checkbox. Right now it has this code attach to it
Code: Select all  Expand view

      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
Image

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
Last edited by hua on Fri Jun 12, 2020 3:07 am, edited 1 time in total.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse: Process filtered rows only

Postby hua » Thu Jun 11, 2020 8:28 am

I got an idea to do it this way. But seems to be caught in an infinite loop
Code: Select all  Expand view

    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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: xBrowse: Process filtered rows only

Postby hua » Thu Jun 11, 2020 9:44 am

Ok. This version seems to work
Code: Select all  Expand view

      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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 48 guests