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

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.

WARNING
The use of libraries for personal and / or commercial use is permitted. It is not allowed to modify the sources or change the name of the library. Reverse engineering is not authorized to access the sources for any reason, not even for study or learning reasons.

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.45
  • 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)
      • FeetClick (Index As Int)
      • HeadClick (Index As Int)
      • Modified (Row As Int, Col As Int)
      • ScrollX (Position As Double)
      • ScrollY (Position As Double)
    • Fields:
      • EditBackgroundColor As Int
      • EditTextColor As Int
      • TypeButton As Int
      • TypeCheck As Int
      • TypeDouble As Int
      • TypeFloat As Int
      • TypeImage As Int
      • TypeInt As Int
      • TypeList 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)
      • AddRowCustomize (Cell As Object(), Text_Color As Int, Background_Color As Int, TextFont As B4XFont, Refresh As Boolean) As String
      • 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)
      • SearchInColumn (Text As String, Col As Int, FromRow As Int, exactly As Boolean, IgnoreCap As Boolean) As Int
        Search for text in the indicated column starting from the start row.
        If the start row is 0 it will check the entire column.
        It will return the position of the line containing the text
        <code>Dim Col As Int = 5
        Dim Row As Int = FlexGied1.SearchInColumn("My text",Col,0, False, True)
        if Row>-1 then Log("Find in row " & Row) Else log("Don't find")
        </code>
      • SearchInColumn2 (Text As String, Col As Int, FromRow As Int, exactly As Boolean, IgnoreCap As Boolean) As List
        Search for text in the indicated column starting from the start row.
        If the start row is 0 it will check the entire column.
        It will return the list of position of the line containing the text
        <code>Dim Col As Int = 5
        Dim IndexFinded As List = FlexGied1.SearchInColumn2("My text",Col,0, False, True)
        if IndexFinded.Size>0 then Log("Find in row " & Row) Else log("Don't find")
        </code>
      • SelectCell (Row As Int, Col As Int, Mobile As Boolean) As String
        eg. Flexgrid.SelectCell(1,1,True)
        If Mobile 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 Mobile 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))
      • SetCellListIndex (Row As Int, Col As Int, Index As Int) As String
      • 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)
        eg. Flexgrid.SetCellValue(Row,Col,"A,B,C,D,E") for TypeList
      • 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")
      • SetColsNumber (ColumnNumber As Int) As String
        Reset Grid and Change Cols Number
      • 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)
      • SetDataRow (Row As Int, Cell As Object()) As String
        eg. Flexgrid.SetRow(Row,Array As Object(i,B,"User ","Description " ,100.00))
      • SetDataRow2 (Row As Int, Cell As Object(), HeightRow As Int) As String
        eg. Flexgrid.SetRow2(Row,Array As Object(i,B,"User ","Description " ,100.00),40dip)
      • SetFeetHeight (Height As Int) As String
        Set Header Height
      • setFootColValue (col As Int, Fv As String) As String
        eg. Flexgrid.FeetValue=array As String ("First","Second")
      • setHeaderAlignment (Col As Int, Alignment As String) As String
        eg. Flexgrid.HeaderAlignment="CENTER"
      • SetHeadHeight (Height As Int) As String
        Set Header Height
      • SetPadding (Left As Int, Top As Int, Right As Int, Bottom As Int) As String
        eg. FlexGrid1.SetPadding(10dip,0,10dip,0)
      • 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)
      • SetRowsHeight (Height As Int) As String
        Set all Rows Height
      • SetSingleLine (SLine As Boolean) As String
        To set the cells to single or multiple lines
      • SortForCol (Column As Int) As String
    • Properties:
      • Base As B4XView [read only]
      • ColCount As Int [read only]
      • ColorSelectedArea
        Set the color of the selected area
      • ColorSelectingArea
        Set the color of the area during the selection phase
      • ColsAlignment
        eg. setColsAlignment(Array As String ("LEFT","CENTER","CENTER","RIGHT"))
      • ColsName As String()
        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.Font=xui.CreateDefaultFont(12)
      • FootFont
        eg. Flexgrid.FeetFont=xui.CreateDefaultFont(12)
      • FootValue As String()
        eg. Flexgrid.FeetValue=array As String ("First","Second")
      • FootVisible
        eg. FG.FeetVisible=True
      • HeaderFont
        eg. Flexgrid.HeaderFont=xui.CreateDefaultFont(12)
      • HeaderVisible
        eg. FG.HeadVisible=True
      • Height As Int
      • RowCount As Int [read only]
        Dim Size as int = Flexgrid.RowCount
      • ScrollToCol
        eg. Flexgrid.ScroolToCol=50 (Col= 0..Size-1)
      • ScrollToRow
        eg. Flexgrid.ScroolToRow=50 (Row= 0..Size-1)
      • ScrollX As Double
      • ScrollY As Double
      • 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
      • Width As Int


Video1.gif
Video2.gif
Video4.gif

Video5.gif
Video6.gif
Video3.gif


List/Spinner
video7-gif.118379


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

Significative release logs:
  • 0.12
    • Add method SelectCells (FromRow As Int, FromCol As Int, ToRow As Int, ToCol As Int, Mobile As Boolean)
    • Modify method SelectCell (Row As Int, Col As Int, Mobile As Boolean)
  • 0.15: Added HeaderFont
  • 0.16: Added SetColsNumber method.
  • 0.19 (Sample)
    • Add method AddRowCustomize (Cell As Object()
    • Add method SearchInColumn (Text As String, Col As Int, FromRow As Int, exactly As Boolean, IgnoreCap As Boolean) As Int
  • 0.21
    • Add TypeList. Allows you to add a ComboBox type box (Spinner in B4A and Picker in B4i) and select to a list
    • Added other examples to POST n. 2 To populate the grid from the database, search for a string in a column and to use TypeList in the grid
    • added SetCellListIndex method to change the position of the selected index
  • 0.25
    • Added SetHeadHeight method
      sets the height of the header
    • Added SetRowsHeight method
      sets the height of all lines
  • 0.27
    • added properties ScrollX and ScrollY
    • Added events ScrollX() and ScrollY()
  • 0.29: Fixed bugs in vertical scrolling
  • 0.31
    • Added SortForCol(Column As Int)
    • Added SetDataRow(Row As Int, Cell() As Object) and SetDataRow2(Row As Int, Cell() As Object, HeightRow As Int)
    • Added field ColorSelectedArea and ColorSelectingArea
    • Fix bug
  • 0.32
    • Added SearchInColumn2. Returns the list of search result lines
  • 0.33
    • Added setHeaderAlignment
  • 0.34
    • Added the ability to freeze the last row (foot row) as well as the header so you can enter column totals that always remain visible
    • Fix minor bugs
  • 0.35
    • Added the ability to select from Design that text cells are single or multiline
  • 0.36
    • Fix bugs: SortForCol; SetColsNumber
  • 0.37
    • Added: EditTextColor and EditBackgroundColor fields to be able to select colors for the on-site editable cell. By default it is black background and white text
  • 0.38
    • Fixed bug on CheckBox alignment
  • 0.39
    • Singleline and multiline option of the design now also affects the column header and column foot
  • 0.40
    • Added ScrollToCol (together with ScrollToRow it is possible to position in a specific cell)
  • 0.41
    • Fix bug
  • 0.42
    • Added Width and Height to change the size of the grid from code during execution
  • 0.43
    • Fixed bug on SearchInColumn2
  • 0.44
    • Added SetSingleLine - To set the cells to single or multiple lines
  • 0.45
    • Added SetPadding
 

Attachments

  • B4A Sample.zip
    31 KB · Views: 1,526
  • B4i Sample.zip
    24.2 KB · Views: 805
  • B4j Sample.zip
    23.9 KB · Views: 1,241
  • SD_FlexGrid 0.45.zip
    37.9 KB · Views: 450
  • jSD_FlexGrid 0.45.zip
    38.7 KB · Views: 339
  • iSD_FlexGrid 0.45.zip
    327.4 KB · Views: 294
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Create a For loop for the cells you want to clear the contents and then use SetCellValue (Row As Int, Col As Int, Value As Object)
If you want to completely eliminate the rows, use the RemoveRow (Row As Int) command
 

Pravee7094

Active 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 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.13
  • 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
      • ClearRow 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)
      • 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)
      • 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


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/[/I]
Can I save this data in SQLite Database? How?
 

Pravee7094

Active 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 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.13
  • 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
      • ClearRow 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)
      • 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)
      • 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


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/[/I]
Hi sir,
How can I add more than six columns? Is there possible? or only can add within 6 columns?

Regards
Praveen
 

Star-Dust

Expert
Licensed User
Longtime User
Can I save this data in SQLite Database? How?
Hi sir,
it is possible to load, update or insert data from a database or to a database, building the procedure. there is no automatic procedure. You will have to read the cell values and update or add to the database.


Hi sir,
How can I add more than six columns? Is there possible? or only can add within 6 columns?

Regards
Praveen
I find this question strange. I don't read anywhere that it says there is a limit of rows or columns. Rather there are properties that let you know the number of rows and columns, so anyone would assume that there is no fixed number. Maybe you phrased the question wrong and wanted to ask something else?
 

Pravee7094

Active Member
Hi sir,
it is possible to load, update or insert data from a database or to a database, building the procedure. there is no automatic procedure. You will have to read the cell values and update or add to the database.



I find this question strange. I don't read anywhere that it says there is a limit of rows or columns. Rather there are properties that let you know the number of rows and columns, so anyone would assume that there is no fixed number. Maybe you phrased the question wrong and wanted to ask something else?
Hello Sir, Thanks for your response.
If I add more than six columns, That error will be appear. What can I do sir.

B4X:
    if_flexgrid.ColsName=Array As String("Barcode","ItemName","Price","BeforeTax","AfterTax","SalesPrice","cc")
    if_flexgrid.ColsWidth=Array As Int(75dip,75dip,75dip,75dip,75dip,75dip,75dip)

Error Message:

Error occurred on line: 42 (Main)
java.lang.IndexOutOfBoundsException: Index: 6, Size: 6
at java.util.ArrayList.get(ArrayList.java:437)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example.flexgrid._createheader(flexgrid.java:872)
at b4a.example.flexgrid._invalidate(flexgrid.java:1668)
at b4a.example.flexgrid._setcolswidth(flexgrid.java:2306)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:226)
at android.app.ActivityThread.main(ActivityThread.java:7178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

Any suggestion or Help?

Regards
Praveen
 

Pravee7094

Active Member
Hello Sir, Thanks for your response.
If I add more than six columns, That error will be appear. What can I do sir.

B4X:
    if_flexgrid.ColsName=Array As String("Barcode","ItemName","Price","BeforeTax","AfterTax","SalesPrice","cc")
    if_flexgrid.ColsWidth=Array As Int(75dip,75dip,75dip,75dip,75dip,75dip,75dip)

Error Message:

Error occurred on line: 42 (Main)
java.lang.IndexOutOfBoundsException: Index: 6, Size: 6
at java.util.ArrayList.get(ArrayList.java:437)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example.flexgrid._createheader(flexgrid.java:872)
at b4a.example.flexgrid._invalidate(flexgrid.java:1668)
at b4a.example.flexgrid._setcolswidth(flexgrid.java:2306)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.example.main.afterFirstLayout(main.java:105)
at b4a.example.main.access$000(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:226)
at android.app.ActivityThread.main(ActivityThread.java:7178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:942)

Any suggestion or Help?

Regards
Praveen
sorry sir, My mistake. Solved
 

Sabotto

Well-Known Member
Licensed User
Maybe he was misled by the example, where there are just 6 columns ...
B4X:
FlexGrid1.ColsName=Array As String("","N","On","Name","Img","Digit")
FlexGrid1.ColsWidth=Array As Int(75dip,50dip,50dip,100dip,60dip,100dip)
 

Star-Dust

Expert
Licensed User
Longtime User
Maybe he was misled by the example, where there are just 6 columns ...
B4X:
FlexGrid1.ColsName=Array As String("","N","On","Name","Img","Digit")
FlexGrid1.ColsWidth=Array As Int(75dip,50dip,50dip,100dip,60dip,100dip)
In the Design you set the number of columns
 

Star-Dust

Expert
Licensed User
Longtime User
padding to cells?
 

Star-Dust

Expert
Licensed User
Longtime User
It is not possible to change the thickness of the frame that distances the view from the grids.
 

Pravee7094

Active Member
Hi sir,

I used your inline editable table. Your work just awesome.
In mobile mode, Border cell was worked as perfect.
But In tablet mode, I can't see the Border cell. It doesn't work as well.

Any Suggestion sir?
Thank you
 

Pravee7094

Active Member
How I set, No one could not edit this specific column?

B4X:
Sub if_flexgrid_CellClick(Row As Int, Col As Int)
    If Col=0 Then
        if_flexgrid.SelectRow(Row)
    Else
        Select if_flexgrid.GetTypeCol(Col)
            Case if_flexgrid.TypeString
                Dim S As String = if_flexgrid.GetCellValue(Row,Col)
                Log("Cell content: " & S)
                if_flexgrid.EditCellonsite(Row,Col)
        End Select
    End If

End Sub

In the above coding can edit every "typestring" method.

But I want another one. Here
For example, I have two columns. one is "Fullname" and another one is "mobilenumber" both are "typestring" method
but I want "Fullname" field as editable and "mobilenumber " field is not editable. But both are "typestring" method

How to do that?
Any suggestion ?

Thanks
Praveen
 

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Sub if_flexgrid_CellClick(Row As Int, Col As Int)
    If Col=0 Then
        if_flexgrid.SelectRow(Row)
    Else if Col=2 Then ' Col-2 is  Fullname Column
               Dim S As String = if_flexgrid.GetCellValue(Row,Col)
               Log("Cell content: " & S)
               if_flexgrid.EditCellonsite(Row,Col)
    End If

End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
I have not encountered this problem.
I have attached the screenshot of the test I did

Screenshot_20210513-070719.png
 

Pravee7094

Active Member
Hi sir,
For example, I have 10 columns in the table.
I want to Hide particular 5 columns from the table.
I mean I should set visible false.

Can I do that in this table?
Any suggestion?

Thanks
 
  • Like
Reactions: omo
Top