Android Code Snippet cGrid

I wrote this cGrid class and cGridx (code module) to have a scrolling grid to use for my Golf scoring program and other programs.

I've made an example program that puts up a grid with 1 fixed column and 2 fixed header lines and multiple scrolling lines. NOTE: Example was made for 7" Samsung but should work on anything

If you click on some of the options in the testline you can see how things work and clicking on the player score boxes (where you would put a player score) and random score is chosen and put in the box and then the automatic totaling adds to the Out / In and Total boxes. ALL Totaling (Yardage, Par and Player Scoring is done by an internal grid routine)

This is a light version of the grid I will convert more routines as I have time to clean them up and add them to the cGrid class.

Couple of note: All the data displayed is hard coded in real life I get it from a database
Scrolling works fine in Release mode but lags behind when using the debugger
Checkbox bitmap and DropDown arrow are text strings in program

Hope this helps someone needing a grid

Enjoy

BobVal


1/19/2017 - Removed non needed optional parms (Statelist, Bitmap - Now just Background will handle Bitmaps, Drawables, Statelist)
Removed UseSize optional parm (Size is still there)
 

Attachments

  • Golf-170118111850.jpg
    Golf-170118111850.jpg
    189.3 KB · Views: 565
  • Golf-170118111900.jpg
    Golf-170118111900.jpg
    159.1 KB · Views: 550
  • Grid.zip
    51.4 KB · Views: 359
Last edited:

DroidLyon

Member
Licensed User
Longtime User
Hi Bob

Sorry for being a noob but I'm simply trying to "get" data (names, tel, address etc) from a populated grid cell using your class?

For the purposes of explaining better I can see in your latest example that mgrid.getcolumntext is used as in

B4X:
Sub Player_Hole_Click(EventParameter As TcGridEventParameter)

Dim ParRowCol As TcGridRowCol = cGridx.MakeCopy(EventParameter.RowCol)
etc ..
Dim HolePar   As String  = mGrid.GetColumnText(ParRowCol)

If I added log("holepar = " & mGrid.GetColumnText(ParRowCol) ) in this sub it will log the "cell data" (2,3,4,5 etc) and similarly if I use these lines in the Player_name_click sub it will display "Bob" or "Pat" in the log depending on which name I click :)

So is using mGrid.GetColumnText(ParRowCol) essentially the right way to "get" cell data in your class?

I actually confused myself when looking at the same Player_name_sub and hoping that adding
Log("name is " & EventParameter.Data) in the sub might do something ?! but it returns null
I noted that cGridx comments say
' Event Parameter is sent to the routine when the selected event is triggered
' Data will be one of the following.
' If the Column Data has been set then it will be the Column Data
' Else if the Row Data has been set then it will be the Row Data
' Else it will be null

But I think I need to think a bit more about what this actually does first before asking anything else about it ! ..

BTW thanks in advance for your time (and for your class !)
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Yes getting text is done to the GetColumnText (now if you need to get all the data at once you could add a routine to return a list of all the individual columns data)

"Data" - Row Data or Column Data is User Passed Data.

As an example

Type SQLCustomerRecord(RecordID as Long, CustomerName as String, ...)
Type SQLTransactionRecord(RecordID as Long, CustomerRecordID as Long, TransactionType as String, ...)

So for Each Row I could set the "data" to be the SQL Customer RecordID and for each Column I could set the "data" to be the RecordId of that transaction

This way when I am doing something on a row I know the customer record id on each event and if I am doing something on a column I have the record id for that transaction.

In my golf program (the real working one) I normally set the Row Data to be the PlayerScoring.RecordID so I can always have direct access to who it is in each of the column routines.

"Data" is defined as an Object so it can be ANYTHING you want to store and reference later.

Sure hope this helps
 

DroidLyon

Member
Licensed User
Longtime User
Thanks Bob for clarifying and the quick reply :)

Yes got it re text, and can see need for a routine as you note.

I noticed in the TcGridEventParameter type definition that "data" was an object, but didn't grasp how it works or how much potential it offers.
Now I'm just wondering how much you can do with that potential!

Thanks for explaining.:)
DL
 
Top