B4J Library [B4X] [XUI] SD FlexGrid (Table)

Star-Dust

Expert
Licensed User
Longtime User
Hi, I'll think about it
 

hazaal

Member
Licensed User
Longtime User
Hi,

I have multiple FlexGrids in app, and those are working very well with, but now I have a bit weird problem, I think it's just something that I don't get...

Question - how to change grid height in run time? I have tried grid.base.Height, but it only changes the height of the base(panel?), same qty of rows is shown, while there would be many more to show if the grid.height would be bigger as I can change it in designer.

What am I missing?
 

hazaal

Member
Licensed User
Longtime User
Hi Hazaal
Have you tried the 'setdatarow2' function
Regards
David
Thanks David,

But I have no problems with adding rows or setting the height of them.

My problem is changing the grid height in run-time (not row height), as there is no such properties - FlexGrid1.Height

Br,
-Harri
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.42
  • Added Width and Height to change the size of the grid from code during execution
B4X:
FlexGrid1.Width=300dip
FlexGrid1.Width=FlexGrid1.Width+50dip
FlexGrid1.Height=80%y
 

Star-Dust

Expert
Licensed User
Longtime User

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.44
  • Added SetSingleLine - To set the cells to single or multiple lines by code
 

Star-Dust

Expert
Licensed User
Longtime User
Hello Sir
Show To display only the lines that correspond to certain parameters described in the filter, (FilterView) (when are you planning to implement this feature)
Sd Flexigrid great library.
I'll take note of it, we'll see if it will be possible to include it in the future
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.45
  • Added SetPadding method , to padding the cell
B4X:
FlexGrid1.SetPadding (10dip, 0, 10dip, 0)
 

roby128128

New Member
Update rel 0.45
  • Added SetPadding method , to padding the cell
B4X:
FlexGrid1.SetPadding (10dip, 0, 10dip, 0)
Good morning Stardust, fantastic library for managing databases in the grid, I tried and everything works very well, except the removerow command, if I launch this command the program crashes, can you tell me where I'm wrong. Thank you
 

Star-Dust

Expert
Licensed User
Longtime User
Hi,
you didn't give me the necessary elements to understand the problem. Give a debug and report the error. It would be useful to copy the code portion as well
 

Star-Dust

Expert
Licensed User
Longtime User
Extremely strong, adding a grouping subtotal summation function would be even more perfect
In an example we demonstrate how to handle formulas and you can get what you asked for.
 

roby128128

New Member
In un esempio viene illustrato come gestire le formule e come ottenere ciò che si è chiesto.

In an example we demonstrate how to handle formulas and you can get what you asked for.
Thanks Sturdust, I don't know why for the help but now it works. When before I launched the FlexGrid1.RemoveRow(1) command everything stopped. It resolved itself. Thanks in any case for the help, professional as always
 

Sergio Haurat

Active Member
Licensed User
Longtime User
Hi, I'll think about it
I wrote this post at different times, my language is not English and if there are any errors in grammar I hope everyone can understand my comments

Column name and column HeaderText:

In Visual Studio, DataGridView has two separate properties relative to the header in the column collection.

1. The actual name of the column, which can be accessed as an object. The property name is "name"
2. User-friendly column text named "HeaderText"

It would be very useful to be able to differentiate the column object from a text that the user views in the header. If you want to do it, thinking about projects that use SD_FlexGrid, if the HeaderText is not specified, you get a copy of the "name"as HeaderText.

Tag property:

There a way to add a "Tag" property to each cell? This is useful for assigning an identifier. In my case I have a person who has an identification number. To get the data, if I don't want to show the ID number, I need to add a column with "0dip" so that column is not shown:

Code in my proyect:
    FlexGrid1.ColsName = Array As String("", "Name", "Player present", "Player absent with justification", "Player absent without justification", "Player absent due to injury"))
    FlexGrid1.ColsWidth = Array As Int(0dip, 180dip, 78dip, 78dip, 78dip, 78dip)
    FlexGrid1.ColsType = Array As Int(dgvView.TypeInt, dgvView.TypeString, dgvView.TypeCheck, dgvView.TypeCheck, dgvView.TypeCheck, dgvView.TypeCheck)
    FlexGrid1.ColsAlignment = Array As String("CENTER", "CENTER", "CENTER", "CENTER", "CENTER", "CENTER")

An idea of assigning a value to the Tag property

Tag:
FlexGrid.SetCellTag(Row, Col) = 12345678

Export data:

Finally, the Tag property and the inclusion of HeaderText would be very useful for what follows:

I didn't find a function that saves the content to a JSON object or any other type., for this reason I made my own procedure. This is a version that can be improved, but for the moment, it is only functional to my needs for this particular project.

Example:
Sub Dummy()
  'With the HeaderText property separated from name, lstCols parameter would not be necessary.
  Dim lstCols(6) As String
  lstCols(0) = "clb_asistencias_id" 'This is the place of the property Tag
  lstCols(1) = "clb_asistencias_pre"
  lstCols(2) = "clb_asistencias_aca"
  lstCols(3) = "clb_asistencias_asa"
  lstCols(4) = "clb_asistencias_apl"
  Dim strJSON As Object = WriteTableToJSONString(FlexGrid1, lstCols)
End Sub

Public Sub WriteTableToJSONString(objTbl As FlexGrid, lstColsName() As String) As ResumableSub
  Dim strJSON As String = "["
  Dim strValue As String = ""
  For intRow = 0 To objTbl.RowCount - 1
    strJSON = strJSON & "{"
    For intCol = 0 To objTbl.ColsName.Length - 1
      Dim strColName As String = lstColsName(intCol)
      Select objTbl.GetTypeCol(intCol)
        Case objTbl.TypeString
          strValue = QUOTE & objTbl.GetCellValue(intRow, intCol) & QUOTE & ","
        Case objTbl.TypeFloat, objTbl.TypeInt
          strValue = objTbl.GetCellValue(intRow, intCol) & ","
        Case Else
          If objTbl.GetCellValue(intRow, intCol) = True Or objTbl.GetCellValue(intRow, intCol) = False Then
            strValue = objTbl.GetCellValue(intRow, intCol) & ","
          Else
            strValue = QUOTE & objTbl.GetCellValue(intRow, intCol) & QUOTE & ","
          End If
       End Select
       strJSON = strJSON & QUOTE & strColName & QUOTE & ": " & strValue
    Next
    strJSON = strJSON.SubString2(0, strJSON.Length - 1) & "},"
  Next
  strJSON = strJSON.SubString2(0, strJSON.Length - 1) & "]"
  Return strJSON
End Sub

In the following JSON data example, clb_asistencias_id should be obtained from the Tag property instead of a hidden column

JSON Data Example:
[{
        "clb_asistencias_id": 46955403,
        "clb_asistencias_pre": true,
        "clb_asistencias_aca": false,
        "clb_asistencias_asa": false,
        "clb_asistencias_apl": false
    }, {
        "clb_asistencias_id": 45419355,
        "clb_asistencias_pre": true,
        "clb_asistencias_aca": false,
        "clb_asistencias_asa": false,
        "clb_asistencias_apl": false
    }, {
        "clb_asistencias_id": 46649536,
        "clb_asistencias_pre": true,
        "clb_asistencias_aca": false,
        "clb_asistencias_asa": false,
        "clb_asistencias_apl": false
    }]

Thank you for your time and effort
 
Last edited:

f0raster0

Well-Known Member
Licensed User
Longtime User
We found this library just a couole days ago, really loving this!
Thanks @Star-Dust !!

Question
Can you guide me on how to use icons, such as replacing the images with icons?

Edit: Solved - Please ignore my question
I added for example
B4X:
FlexGrid.AddRow(Array As Object("Test", Chr(0xF244), "text 1"),True)
The key is to change the setting of the FlexGrid to FontAwesome.
Thanks very much!
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…