ReportView Select

Started by JTaylor, January 04, 2021, 04:34:30 PM

Previous topic - Next topic

JTaylor

Should the following (have two attempts, individual and group) select all the rows in my ReportView?   The list that results is valid but it doesn't work and I cannot see why.  I have multi-select and selection-highlighting-extends-to-all-columns selected.

A Select All option would be nice...or did I miss it?

Jim

Code (winbatch) Select


        arr = DialogControlGet(PLR_Handle,"rv_PLR_records",@dcContents)
        tlist = ""
        For x = 0 to ArrInfo(arr,1)-1
          tnum  = arr[x,0]
          tlist = tnum:@TAB:tlist
          DialogControlSet(PLR_Handle,"rv_PLR_records",@dcSelect,tnum)
        Next
        ItemRemove(-1,tlist,@TAB)
message("HEY",tlist)
        DialogControlSet(PLR_Handle,"rv_PLR_records",@dcSelect,tlist)

td

What do you exactly mean by "it doesn't work"?  What result do you get?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Sorry...that would help.

It appears to do nothing.   Everything remains unselected.

If I explicitly set one to be highlighted that works.

Thanks.

Jim

td

You can select any number of items you wish if the style of the control is set to multi-select. Also, you need to account for any rows that have repeat values in the first column.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Understood but that is the problem.  It doesn't do anything and I can't see why.  Do you see any problems with my code?

Jim

JTaylor

Okay.  I figured part of it out.   I have rows with the same value in the first column.  When I make everything unique it works.   How do I make it select all of them?   I tried applying a delimited list of all the values, including duplicates but that didn't work.

Jim

td

The idea conveyed in several places is that you specify a row by its name and if rows repeat you indicate which row by repeating the name in a delimited list. From the help file:

"REPORTVIEW: (s) Toggles the selection state of a row in a REPORTVIEW control. Use the function's set-info (fourth) parameter to indicate the first column text of the row to select or unselect.  The text can be a delimited list to indicate which row should be selected when multiple rows have the same first column text. Use an empty string to unselect all selected rows of a control. Note that the control automatically unselects a selected row when a new row is selected when the control has the singleselect (@csSingleSel) style."

I added the bold text for emphasis.

Now lest we start wringing our hands about how hard this all is there is another option.   You can use the @dcItemText request-code in a for loop to obtain the text to each row's first column with duplicates names as necessary and then select each row.  It requires all of 4 lines of code so it should not wear out the keyboard.

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I did read the help before posting.  More than once.  So how is what you are suggesting different that what I have done already?   

      "I tried applying a delimited list of all the values, including duplicates but that didn't work."

I am obviously doing something wrong and/or missing the obvious but I can't see it and is why I have asked for help.

Jim

td

An example.

Code (winbatch) Select

#DefineSubroutine ExProc(hExRv,ExRv_Event,ExRv_Name,ExRv_EventInfo,ExRv_ChangeInfo)
   switch ExRv_Event                                     
      case @deInit  ; Standard Initialization message
         DialogProcOptions(hExRv,@dePbPush,@TRUE)
         return(@retDefault)

      case @dePbPush
         if ExRv_Name == "SelAll"  ; Select All

            hWndRv = DialogControlGet(hExRv, 'RVEx_1', @dchWnd, 0)
            nRows = SendMessageW( hWndRv, 4100, 0, "")   ;LVM_GETITEMCOUNT == 4100
            for i = 1 to nRows
               strText = DialogControlGet(hExRv, 'RVEx_1', @dcItemText, i)
               DialogControlSet(hExRv, 'RVEx_1', @dcSelect, strText)
            next
            return(@retnoexit )
         elseif ExRv_Name == "DeselAll" ; Deselect All
            DialogControlSet(hExRv, 'RVEx_1', @dcSelect, '')
            return(@retnoexit )
          elseif ExRv_Name == "Exit" ; Quit
            return(@retDefault)
          endif                                             
   endswitch                                               
   return(@retDefault)
#EndSubroutine                                             

aRv = ArrDimension(10, 2)
for i = 1 to 10
   aRv[i, 0] = 'repeated text'
   aRv[i, 1] = i
next

ExRvFormat=`WWWDLGED,6.2`

ExRvCaption=`@DCItemText Example`
ExRvX=595
ExRvY=154
ExRvWidth=393
ExRvHeight=249
ExRvNumControls=004
ExRvProcedure=`ExProc`
ExRvFont=`DEFAULT`
ExRvTextColor=`DEFAULT`
ExRvBackground=`DEFAULT,DEFAULT`
ExRvConfig=0
ExRvDPI=`192,10,20`

ExRv001=`060,209,064,015,PUSHBUTTON,"SelAll",DEFAULT,"Select All",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
ExRv002=`284,209,049,015,PUSHBUTTON,"Exit",DEFAULT,"Quit",0,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ExRv003=`170,209,062,015,PUSHBUTTON,"DeselAll",DEFAULT,"Deselect All",2,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ExRv004=`038,022,314,159,REPORTVIEW,"RVEx_1",aRV,DEFAULT,DEFAULT,40,@csFullSel|@csGrid,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("ExRv")

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I finally figured out how this works.  Thank you.   Not sure the help file makes this very clear and perhaps a bit of clarification there would help others.  At least I read it as being able to apply a TAB delimited list of the entire grid's first column (including duplicates) and it would select the entire grid.   Even with your example it took a bit to figure out why yours worked and mine didn't.   It wasn't until I put in a Message() to display what each method extracted as the value was I able to understand.   In case it helps others I have posted the following:


Using the array I get one value for each row so when I apply it it only selects the first duplicated row.   Again, producing a tab delimited list of the grid's first column doesn't help.

Using DialogControlGet() I get one value for the first row but two (tab-delimited) values for the second, three for the third and so on.  Thus when applying the selection it applies it to the number of rows as of items in the list.

This code will display what happens.

Code (winbatch) Select


  #DefineSubroutine ExVarProc(hExVar,ExVar_Event,ExVar_Name,ExVar_EventInfo,ExVar_ChangeInfo)
   switch ExVar_Event                                     
      case @deInit  ; Standard Initialization message
         DialogProcOptions(hExVar,@dePbPush,@TRUE)
         return(@retDefault)

      case @dePbPush
         if ExVar_Name == "SelAll"  ; Select All

            hWndRv = DialogControlGet(hExVar, 'RVEx_1', @dchWnd, 0)
            nRows = SendMessageW( hWndRv, 4100, 0, "")   ;LVM_GETITEMCOUNT == 4100

            arr = DialogControlGet(hExVar,"RVEx_1",@dcContents)
            nRows =  ArrInfo(arr,1)
            For i = 1 to nRows-1
              strText  = arr[i,0]
              strTex2 = DialogControlGet(hExVar, 'RVEx_1', @dcItemText, i+1)

              If strText != strTex2 Then
                Message(i:" of ":nRows,StrLen(strText):@TAB:strText:@CRLF:@CRLF:StrLen(strTex2):@TAB:strTex2)
              EndIf
              DialogControlSet(hExVar,"RVEx_1",@dcSelect,strTex2)
            Next

            return(@retnoexit )
         elseif ExVar_Name == "DeselAll" ; Deselect All
            DialogControlSet(hExVar, 'RVEx_1', @dcSelect, '')
            return(@retnoexit )
          elseif ExVar_Name == "Exit" ; Quit
            return(@retDefault)
          endif                                             
   endswitch                                               
   return(@retDefault)
#EndSubroutine                                             

aRv = ArrDimension(10, 2)
for i = 1 to 10
   aRv[i, 0] = 'repeated text'
   aRv[i, 1] = i
next

ExVarFormat=`WWWDLGED,6.2`

ExVarCaption=`@DCItemText Example`
ExVarX=595
ExVarY=154
ExVarWidth=393
ExVarHeight=249
ExVarNumControls=004
ExVarProcedure=`ExVarProc`
ExVarFont=`DEFAULT`
ExVarTextColor=`DEFAULT`
ExVarBackground=`DEFAULT,DEFAULT`
ExVarConfig=0
ExVarDPI=`192,10,20`

ExVar001=`060,209,064,015,PUSHBUTTON,"SelAll",DEFAULT,"Select All",1,10,@csDefButton,DEFAULT,DEFAULT,DEFAULT`
ExVar002=`284,209,049,015,PUSHBUTTON,"Exit",DEFAULT,"E&xit",0,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ExVar003=`170,209,062,015,PUSHBUTTON,"DeselAll",DEFAULT,"Deselect All",2,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ExVar004=`038,022,314,159,REPORTVIEW,"RVEx_1",aRV,DEFAULT,DEFAULT,40,@csFullSel|@csGrid,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("ExVar")




Jim

td

The point is that with advent of the @dcItemText option you don't need to concern yourself with the exact composition of the text used to reference a row.  All you need is the one based row number.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

I understand now.   Thanks again.

Jim

kdmoyers

I do a lot of reportview stuff and found this all very educational.  thanks guys!
The mind is everything; What you think, you become.

td

Quote from: JTaylor on January 05, 2021, 10:02:29 AM
I understand now.   Thanks again.

I thought it was clear from my original response,

"Now lest we start wringing our hands about how hard this all is there is another option.   You can use the @dcItemText request-code in a for loop to obtain the text to each row's first column with duplicates names as necessary and then select each row.  It requires all of 4 lines of code so it should not wear out the keyboard."

Then again writing has never been my strong suit.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Not really.   That is the problem with working with idiots like me.   In any event, I now understand.

Jim

td

You are being too hard on yourself.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade