cancel
Showing results for 
Search instead for 
Did you mean: 

How to number rows in the order clicked?

leon_laikan
Participant
0 Kudos

Hi,

I am working on a simple grid in VB.NET.

I have 2 UDF's:

  • U_HandOver (which I turned into a column of checkboxes)
  • U_HOV, (which is a column of EditText)


Each time we tick a checkbox, the number 1 should appear in the same row in  column U_HOV .



My next step is to achieve the foll. aim:

  • When we tick any checkbox, the number 1 should appear in U_HOV.
  • When we tick a 2nd checkbox (anyone), the number 2 should appear.
  • When we tick a 3rd checkbox,(any other one), the number 3 should appear.
  • etc, etc

Hence, as we tick each required checkbox, U_HOV will be numbered in the sequence in which the checkboxes are ticked.

Ideally, if we untick any checkbox, the number on that row should disappear.

Why I want to do this?

In a next stage, I will sort the rows in order in which they are ticked.

It's an application for the Handing over of documents from Store to Accts Dept.

So this trick will remove the necessity of having to sort the documents manually before handing over.

I am short of ideas how to do this?

Anybody can give ideas and/or codes?

My basic code for the click event is as foll:How to modify?

Thanks

Leon Lai

----------------------

If FormUID = "frmGrid" And pVal.BeforeAction = False _

        And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK _

        And pVal.ItemUID = "MyGrid" _

        And pVal.ColUID = "U_HandOver" Then

            Dim oGridRow As Integer = pVal.Row

           If oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y" Then

               oGrid.DataTable.SetValue("U_HOV", oGrid.GetDataTableRowIndex(pVal.Row), 1)

               '

            End If

End If




Accepted Solutions (1)

Accepted Solutions (1)

pedro_magueija
Active Contributor
0 Kudos

Hi Leon,

Create a function that counts the number of checked checkboxes. Then use that + 1 to be the value to fill the U_HOV column.

If FormUID = "frmGrid" And pVal.BeforeAction = False _

        And pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK _

        And pVal.ItemUID = "MyGrid" _

        And pVal.ColUID = "U_HandOver" Then

            Dim oGridRow As Integer = pVal.Row

            Dim nextValue As Integer = CountChecked() + 1;

          If oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y" Then

              oGrid.DataTable.SetValue("U_HOV", oGrid.GetDataTableRowIndex(pVal.Row), nextValue)

          Else

              oGrid.DataTable.SetValue("U_HOV", oGrid.GetDataTableRowIndex(pVal.Row), "")                         

        End If

End If


This is just one idea.


Best regards,

Pedro Magueija


View Pedro Magueija's profile on LinkedIn

leon_laikan
Participant
0 Kudos

Hi Pedro,

Thanks a lot for your reply.

Tomorrow is public holiday here, and I can only test the code on Thursday.

I will let you know.

But I've already grasped your clever idea:

Each time there is a click event, a function calculates how many rows are already clicked.Then, just add 1.

Unticked rows are also cared for.

Seems it will work. I'm impatient to try!

Best Regards,

Leon Lai

Answers (0)