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

Star-Dust

Expert
Licensed User
I created a new library to show a table (or grid) similar to the one in EXCEL.

There are already excellent classes that allow many to accomplish things, such as xCustomListView by @Erel (B4X) and with the FlexibleTable by @klaus (B4A)

I wanted to make something slightly different suited to my needs.

Explanations:
  1. To get the calculation of the cells that contain a formula I have added Erel's B4XEval to my Library, but as soon as possible I will make it external so that everyone can modify it according to their needs.
  2. To select multiple cells, position yourself on the first cell of those to be selected (the one at the top left) click a shot and then click again and drag your finger to cover all the cells (or area) that you want to select
  3. It is still in beta version, presents problems in large grids.
  4. Now only for B4A and B4i Now for B4A,B4i,B4j
  5. In the example to select a group of cells just long click on a cell (not checkbox). In the case of B4J click with the right mouse button

SD_FlexGrid

Author:
Star-Dust
Version: 0.14
  • Eval
    version 2.00
    Eval Method By Erel: https://www.b4x.com/android/forum/threads/b4x-eval-expressions-evaluator.54629/
    • Fields:
      • Error As Boolean
    • Functions:
      • Calculate (Expression As String) As Double
      • Class_Globals As String
      • Initialize (FG As FlexGrid) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
  • FlexGrid
    • Events:
      • CellClick (Row As Int, Col As Int)
      • CellLongClick (Row As Int, Col As Int)
      • HeadClick (Index As Int)
      • Modified (Row As Int, Col As Int)
    • Fields:
      • TypeButton As Int
      • TypeCheck As Int
      • TypeDouble As Int
      • TypeFloat As Int
      • TypeImage As Int
      • TypeInt As Int
      • TypeString As Int
    • Functions:
      • AddRow (Cell As Object(), Refresh As Boolean) As String
        eg. Flexgrid.AddRow(Array As Object(i,B,"User ","Description " ,100.00), True)
      • AddRow2 (Cell As Object(), HeightRow As Int, Refresh As Boolean) As String
        eg. Flexgrid.AddRow(Array As Object(i,B,"User ","Description " ,100.00),40dip,True)
      • AddRowAt (index As Int, Cell As Object(), Refresh As Boolean) As String
        eg. Flexgrid.AddRow(2,Array As Object(i,B,"User ","Description " ,100.00), True)
      • AddToParent (Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int, ColsNumber As Int) As String
        Parent is Panel to Add Grid
        eg. Flexgrid.AddToParent(Activity,0,0,100%x,100%y,5)
      • Class_Globals As String
      • ClearRows As String
        erase all rows contents
      • ClearSelection As String
        cell no longer be selected
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • EditCell (Row As Int, Col As Int) As String
        eg. Flexgrid.EditCell(1,1)
      • EditCellOnSite (Row As Int, Col As Int) As String
        eg. Flexgrid.EditCell(1,1)
      • GetCellBackgroundColor (Row As Int, Col As Int) As Int
      • GetCellCol (Col As Int) As Object()
        eg. Dim S() as String = Flexgrid.GetCellCol(1)
        eg. Dim B() as Boolean = Flexgrid.GetCellCol(2)
      • GetCellRow (Row As Int) As Object()
        eg Dim Row() as Object = Flexgrid.GetCellRow(1)
      • GetCellTextColor (Row As Int, Col As Int) As Int
      • GetCellTextFont (Row As Int, Col As Int) As B4XFont
      • GetCellValue (Row As Int, col As Int) As Object
        eg. Dim I as int = Flexgrid.GetCellValue(1,1)
        eg. Dim S as String = FlexGrid.GetCellValue(2,2)
      • GetTypeCol (Col As Int) As Int
        eg. If Flexgrid.GetTypeCol(1)=Flexgrid.TypeInt Then .....
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • RemoveRow (Row As Int) As String
        Row (0...n-1)
        eg. Flexgrid.RemoveRow(1)
      • ResetCustomizeCell (Col As Int, Row As Int) As String
        eg. Flexgrid.ResetCustomizeCell(1,1)
      • SelectCell (Row As Int, Col As Int, Mobile As Boolean) As String
        eg. Flexgrid.SelectCell(1,1,True)
        If Floating is True, the selectable area can be enlarged by touching and dragging it to the desired box.
      • SelectCells (FromRow As Int, FromCol As Int, ToRow As Int, ToCol As Int, Mobile As Boolean) As String
        eg. Flexgrid.SelectCell(1,1,5,4,True)
        If Floating is True, the selectable area can be enlarged by touching and dragging it to the desired box.
      • SelectCol (Col As Int) As String
        eg. Flexgrid.SelectCol(1)
      • SelectRow (Row As Int) As String
        eg. Flexgrid.SelectRow(1)
      • SetCellCustomize (Row As Int, Col As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetCellCustomize(1,1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetCellValue (Row As Int, Col As Int, Value As Object) As String
        eg. Flexgrid.SetCellValue(1,1,True)
        eg. Flexgrid.SetCellValue(2,2,"OK")
        eg. Flexgrid.SetCellValue(3,3,3)
      • SetColAlignment (ColumnIndex As Int, Alignment As String) As String
        Index (0..n-1)
        eg. SetColAlignment(0,"CENTER")
      • SetColCustomize (Col As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetColCistomize(1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetColName (ColumnIndex As Int, Name As String) As String
        Index (0..n-1)
        eg. Flexgrid.SetColName(1,"Help")
      • SetColType (ColumnIndex As Int, Typ As Int) As String
        Index (0..n-1)
        eg. SetColType(0,FlexGrid.TypeInt)
      • SetColWidth (ColumnIndex As Int, Width As Int) As String
        Index (0..n-1)
        eg. SetColWidth(0,100dip)
      • SetRowCustomize (Row As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetRowCustomize(1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetRowHeight (IndexRow As Int, Height As Int) As String
        IndexRow (0..Size-1)
        eg. setRowHeight(0,60dip)
      • SetTextOrCSBuilderToLabel (lbl_or_Button As B4XView, Text As Object) As String
    • Properties:
      • Base As B4XView [read only]
      • ColCount As Int [read only]
      • ColsAlignment
        eg. setColsAlignment(Array As String ("LEFT","CENTER","CENTER","RIGHT"))
      • ColsName
        eg. Flexgrid.ColName=array As String ("First","Second")
      • ColsType
        eg. ColsType=Array As Int(FlexGrid1.TypeInt,FlexGrid1.TypeCheck,FlexGrid1.TypeString,FlexGrid1.TypeString,FlexGrid1.TypeFloat)
      • ColsWidth
        eg. SetColsWìdth(Array As Int (100dip,50dip,100dip,100dip))
      • Font
        eg. Flexgrid.setFont(xui.CreateDefaultFont(12))
      • RowCount As Int [read only]
        Dim Size as int = Flexgrid.RowCount
      • ScrollToRow
        eg. Flexgrid.ScroolToRow=50
      • SelectedColumnEnd As Int [read only]
        return -1 if not selected
      • SelectedColumnStart As Int [read only]
        return -1 if not selected
      • SelectedRowEnd As Int [read only]
        return -1 if not selected
      • SelectedRowStart As Int [read only]
        return -1 if not selected


Video1.gif
Video2.gif
Video4.gif

Video5.gif
Video6.gif
Video3.gif


For more details: https://www.b4x.com/android/forum/threads/xui-flexgrid.98686/[/I]
 

Attachments

Last edited:

Star-Dust

Expert
Licensed User
I was hoping for feedback from those who used it to understand how to continue the develpe of the library (having the time)
 

monki

Active Member
Licensed User
Hallo star-Dust,
great work but it not work with b4j 7.00?

B4J Version: 7.00
Java Version: 8
Parsing code. (0.07s)
Building folders structure. (0.03s)
Compiling code. (0.10s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
Cannot find: D:\PRG\B4J 7.00\B4J\libraries\xui.jar

monki
 

Cableguy

Expert
Licensed User
You have to copy the XUI libs to the corresponding folders, and select it in the libs tab
 

monki

Active Member
Licensed User
Hallo cableguy,
The Jxui lib is a intern lib und come with the Installation.
The jxui lib is in the internal lib folder and jxui is selected in the libs tab.
Die error Log say " Cannot find: D:\PRG\B4J 7.00\B4J\libraries\xui.jar"
The xui.jar is the Name of the B4A xui lib.

Monki
 

Star-Dust

Expert
Licensed User
Hallo star-Dust,
great work but it not work with b4j 7.00?

B4J Version: 7.00
Java Version: 8
Parsing code. (0.07s)
Building folders structure. (0.03s)
Compiling code. (0.10s)
Compiling layouts code. (0.00s)
Organizing libraries. (0.00s)
Compiling generated Java code. Error
Cannot find: D:\PRG\B4J 7.00\B4J\libraries\xui.jar

monki
I'm sorry, but as you have observed from the files I have not released the version for B4J yet, but only B4A and B4i.
You are using the Android version on B4J
 

Cableguy

Expert
Licensed User
Also, as stated In the release thread, this lib is BETA so it is not unusual for it to be... Not complete(ly) XUI
 

Star-Dust

Expert
Licensed User
Why not!? @Erel has realeased XUI libs that only target B4J and B4A, not b4i... He does however need to make this CLEAR in the release thread!
True, for example, the B4X libraries were announced only for B4A and B4J but only after a few weeks we were able to use them in B4i. But the thread was marked B4X.

There are other examples in this regard, but I do not want to prolong and i want to avoid controversy. I prefer to remove B4X and put it back when I add the B4J version.
 
Last edited:

Robert Valentino

Well-Known Member
Licensed User
I was checking out your example program and was trying to figure out what causes the below routine to get called 21 times when the program starts?

B4X:
Sub FlexGrid1_CellClick(Row As Int, Col As Int)
    If Col=0 Then
        FlexGrid1.SelectRow(Row)
    Else
        Select FlexGrid1.GetTypeCol(Col)
            Case FlexGrid1.TypeCheck
                Dim B As Boolean = FlexGrid1.GetCellValue(Row,Col)
                Log("Cell content: " & B)
            Case FlexGrid1.TypeImage
'                Dim Bm As Bitmap = FlexGrid1.GetCellValue(Row,Col)
'                Log("Cell content: " & Bm)
            Case FlexGrid1.TypeInt
                Dim I As String = FlexGrid1.GetCellValue(Row,Col)
                Log("Cell content: " & I)
                FlexGrid1.EditCellonsite(Row,Col)
            Case FlexGrid1.TypeFloat
                Dim F As String = FlexGrid1.GetCellValue(Row,Col)
                Log("Cell content: " & F)
            Case FlexGrid1.TypeDouble
                Dim D As String = FlexGrid1.GetCellValue(Row,Col)
                Log("Cell content: " & D)
            Case FlexGrid1.TypeString
                Dim S As String = FlexGrid1.GetCellValue(Row,Col)
                Log("Cell content: " & S)
        End Select
    End If
End Sub
 

sn_nn

Member
Licensed User
Very nice grid! But, can i scroll SD_flexgrid to some Column? (Using some like ScrollToCol=15)
 
Last edited:

Star-Dust

Expert
Licensed User
Very nice grid! But, can i scroll SD_flexgrid to some Column? (Using some like ScrollToCol=15)
Sorry for the late reply. I hadn't seen the message.
There is no such function yet,
 

Xfood

Well-Known Member
Licensed User
and this beautiful grid, could you add the search like b4xtable, and if I don't ask much the possibility to order the columns like b4xtable? thank you so much
 

Star-Dust

Expert
Licensed User
and this beautiful grid, could you add the search like b4xtable, and if I don't ask much the possibility to order the columns like b4xtable? thank you so much
Unfortunately, this feature is not currently implemented
 

yuhaowang

Member
I created a new library to show a table (or grid) similar to the one in EXCEL.

There are already excellent classes that allow many to accomplish things, such as xCustomListView by @Erel (B4X) and with the FlexibleTable by @klaus (B4A)

I wanted to make something slightly different suited to my needs.

Explanations:
  1. To get the calculation of the cells that contain a formula I have added Erel's B4XEvalto my Library, but as soon as possible I will make it external so that everyone can modify it according to their needs.
  2. To select multiple cells, position yourself on the first cell of those to be selected (the one at the top left) click a shot and then click again and drag your finger to cover all the cells (or area) that you want to select
  3. It is still in beta version, presents problems in large grids.
  4. Now only for B4A and B4i


SD_FlexGrid

Author:
Star-Dust
Version: 0.05
  • Eval
    By Erel Uziel
    • Fields:
      • Error As Boolean
    • Functions:
      • Calculate (Expression As String) As Double
      • Class_Globals As String
      • Initialize (FG As FlexGrid) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
  • FlexGrid
    • Events:
      • CellClick (Row As Int, Col As Int)
      • CellLongClick (Row As Int, Col As Int)
      • HeadClick (Index As Int)
      • Modified (Row As Int, Col As Int)
    • Fields:
      • ActiveCheckBox As Boolean
      • TypeButton As Int
      • TypeCheck As Int
      • TypeDouble As Int
      • TypeFloat As Int
      • TypeImage As Int
      • TypeInt As Int
      • TypeString As Int
    • Functions:
      • AddRow (Cell As Object(), Refresh As Boolean) As String
        eg. Flexgrid.AddRow(Array As Object(i,B,"User ","Description " ,100.00), True)
      • AddRow2 (Cell As Object(), HeightRow As Int, Refresh As Boolean) As String
        eg. Flexgrid.AddRow(Array As Object(i,B,"User ","Description " ,100.00),40dip,True)
      • AddRowAt (index As Int, Cell As Object(), Refresh As Boolean) As String
        eg. Flexgrid.AddRow(2,Array As Object(i,B,"User ","Description " ,100.00), True)
      • AddToParent (Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int, ColsNumber As Int) As String
        Parent is Panel to Add Grid
        eg. Flexgrid.AddToParent(Activity,0,0,100%x,100%y,5)
      • Class_Globals As String
      • ClearRow As String
      • ClearSelection As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • EditCell (Row As Int, Col As Int) As String
        eg. Flexgrid.EditCell(1,1)
      • EditCellOnSite (Row As Int, Col As Int) As String
        eg. Flexgrid.EditCell(1,1)
      • GetCellCol (Col As Int) As Object()
        eg. Dim S() as String = Flexgrid.GetCellCol(1)
        eg. Dim B() as Boolean = Flexgrid.GetCellCol(2)
      • GetCellRow (Row As Int) As Object()
        eg Dim Row() as Object = Flexgrid.GetCellRow(1)
      • GetCellValue (Row As Int, col As Int) As Object
        eg. Dim I as int = Flexgrid.GetCellValue(1,1)
        eg. Dim S as String = FlexGrid.GetCellValue(2,2)
      • GetTypeCol (Col As Int) As Int
        eg. If Flexgrid.GetTypeCol(1)=Flexgrid.TypeInt Then .....
      • Initialize (Callback As Object, EventName As String) As String
      • Invalidate As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • RemoveRow (Row As Int) As String
        Row (0...n-1)
        eg. Flexgrid.RemoveRow(1)
      • ResetCustomizeCell (Col As Int, Row As Int) As String
        eg. Flexgrid.ResetCustomizeCell(1,1)
      • SelectCell (Row As Int, Col As Int) As String
        eg. Flexgrid.SelectCell(1,1)
      • SelectCol (Col As Int) As String
        eg. Flexgrid.SelectCol(1)
      • SelectPanel_Touch (Action As Int, X As Float, Y As Float) As String
      • SelectRow (Row As Int) As String
        eg. Flexgrid.SelectRow(1)
      • SetCellCustomize (Row As Int, Col As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetCellCustomize(1,1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetCellValue (Row As Int, Col As Int, Value As Object) As String
        eg. Flexgrid.SetCellValue(1,1)=True
        eg. Flexgrid.SetCellValue(2,2)="OK"
        eg. Flexgrid.SetCellValue(3,3)=3
      • SetColAlignment (ColumnIndex As Int, Alignment As String) As String
        Index (0..n-1)
        eg. SetColAlignment(0,"CENTER")
      • SetColCustomize (Col As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetColCistomize(1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetColName (ColumnIndex As Int, Name As String) As String
        Index (0..n-1)
        eg. Flexgrid.SetColName(1,"Help")
      • SetColType (ColumnIndex As Int, Typ As Int) As String
        Index (0..n-1)
        eg. SetColType(0,FlexGrid.TypeInt)
      • SetColWidth (ColumnIndex As Int, Width As Int) As String
        Index (0..n-1)
        eg. SetColWidth(0,100dip)
      • SetRowCustomize (Row As Int, Text_Color As Int, Background_Color As Int, TextFont As B4XFont) As String
        eg. Flexgrid.SetRowCustomize(1,XUI.Color_Black,XUI.Color_White,XUi.CreateDefaultFont(12))
      • SetRowHeight (IndexRow As Int, Height As Int) As String
        IndexRow (0..Size-1)
        eg. setRowHeight(0,60dip)
    • Properties:
      • Base As B4XView [read only]
      • ColsAlignment
        eg. setColsAlignment(Array As String ("LEFT","CENTER","CENTER","RIGHT"))
      • ColsName
        eg. Flexgrid.ColName=array As String ("First","Second")
      • ColsType
        eg. ColsType=Array As Int(FlexGrid1.TypeInt,FlexGrid1.TypeCheck,FlexGrid1.TypeString,FlexGrid1.TypeString,FlexGrid1.TypeFloat)
      • ColsWidth
        eg. SetColsWìdth(Array As Int (100dip,50dip,100dip,100dip))
      • Font
        eg. Flexgrid.setFont(xui.CreateDefaultFont(12))
      • RowCount As Int [read only]
        Dim Size as int = Flexgrid.RowCount
      • ScrollToRow
        eg. Flexgrid.ScroolToRow=50
  • OrderData
    • Fields:
      • Added As Int
      • Index As Int
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Level As Int
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
  • ParsedNode
    • Fields:
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Left As ParsedNode
      • NodeType As Int
      • Operator As String
      • Right As ParsedNode
      • Value As Double
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
View attachment 75757 View attachment 75758 View attachment 75760
View attachment 75761 View attachment 75762 View attachment 75759

For more details: https://www.b4x.com/android/forum/threads/xui-flexgrid.98686/
Hello. How can I always locate it in the last line
Flexgrid.ScroolToRow=bottom?
Flexgrid.TopRow = Flexgrid.Rows - 1?
 

Star-Dust

Expert
Licensed User
Hello. How can I always locate it in the last line
Flexgrid.ScroolToRow=bottom?
Flexgrid.TopRow = Flexgrid.Rows - 1?
B4X:
Flexgrid.ScrollToRow=FlexGrid.RowCount
 
Last edited:
Top