Skip to Content

How to number rows in the order clicked?

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




Capture.JPG (148.1 kB)
Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Dec 09, 2014 at 03:57 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.