0

I'm working with a grid that allows selection. I have a variable whose Control Type is Check Box.

I want to enable a button if at least one row is selected, otherwise the button should be disable.

To achieve this I'm using the event "Click" of the CheckBox variable.

How can I get the number of selected rows? Thanks in advance.

Environment: (C# Web) GeneXus X Evolution 2 Version: 10.2.54798

4

2 回答 2

3

Try this:

Event Refresh
    &count = 0
EndEvent

Event Checkbox.Click
    if Checkbox = true
        &count += 1
    else
        &count -= 1
    endif
    if &count > 0
        Button.enabled = 1
    else
        Button.enabled = 0
    endif
EndEvent

In this sample &count has the number of selected rows.

于 2014-02-19T18:42:40.533 回答
0

you can also do

Event Refesh
   &count = 0
   for each line in Grid
      if Checkbox
        &count += 1
      endif
   endfor
   Button.enabled = (&count > 0)
EndEvent

Also, if you dont actually care how many lines selected and you only want to know if there is at least one, you can put an exit when you enter the if Checkbox condition and instead of a &count variable you can just have a boolean &haveRowSelected, like this:

Event Refesh
   &haveRowSelected = false
   for each line in Grid
      if Checkbox
        &haveRowSelected = true
        exit
      endif
   endfor
   Button.enabled = haveRowSelected 
EndEvent

Hope it helps.

于 2019-12-11T03:53:29.440 回答