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

Star-Dust

Expert
Licensed User
Longtime User
Update 0.14
  • Fix Bugs
  • Method name change: From ClearRow to ClearRows
 

epiCode

Active Member
Licensed User
@Star-Dust great lib !!!

Some questions for you
Is it possible ...
1. to hide columns? (not delete - we can refer to them programmatically but they are not displayed)
2. for Grid to be opened as read only - except checkbox should respond to user inputs
3. for Row header to be invisible
4. for cell to expand on double tap and resize when focus is moved to another cell
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.15
  • Added HeaderFont property to change the header font
  • Added example to post # 2 on how to populate the grid from a db
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Update rel. 0.16
  • Added SetColsNumber method. Allows you to set the number of columns by code. When the number of columns is set, the grid will be cleared.
 

Star-Dust

Expert
Licensed User
Longtime User
  1. You can set the column width to 0dip and it will be invisible
  2. I'm not sure I understand what you want
  3. You can do it from Design
  4. I don't understand what it's for. In B4A and B4J you can edit in an enlarged box with the EditCell command
 

qle

Member
Licensed User
Longtime User
Hi,
Great library, Thanks, (donated)

i have one issue, and that it seems last row is not added

B4X:
      .
    FlexGrid1.ColsName=Array As String("Size","Qty")
    FlexGrid1.ColsWidth=Array As Int(50dip,48dip)
    FlexGrid1.ColsType=Array As Int(FlexGrid1.TypeString,FlexGrid1.TypeString)
    FlexGrid1.ColsAlignment=Array As String("RIGHT","LEFT")
    FlexGrid1.SetColCustomize(0,xui.Color_Black  ,xui.Color_RGB(255,255,255),xui.CreateDefaultFont(14))
    FlexGrid1.SetColCustomize(0,xui.Color_Blue   ,xui.Color_RGB(255,255,255),xui.CreateDefaultFont(14))

    For i=1 To 100
        Log("adding: B" &i&", "&i)
        FlexGrid1.AddRow(Array As Object("B" &i&" "," "&i),True)
    Next

log shows 'adding: B100, 100'
grid last row shows only 99

Lee.
 

Star-Dust

Expert
Licensed User
Longtime User
I guess you're talking about B4A.
Download update 0.16 again and you shouldn't have the problem
 
Last edited:

qle

Member
Licensed User
Longtime User
Hi,
Sorry, yes B4A
I had already installed 0.16,

i have now done it again to make sure, still no change

Adding 10 rows
B4X:
    For i=1 To 10
        Log("adding: B" &i&", "&i)
        FlexGrid1.AddRow(Array As Object("B" &i&" "," "&i),True)
    Next

it shows


But, if i add the FlexGrid1_CellClick, and tap a cell, then the last row appears
I have attached my test project

Note: The version in the SD_FlexGrid.xml is still 15 (but the FlexGrid1.SetColsNumber now exists)
<version>0.15</version>
<author>Star-Dust</author>

Lee
 

Attachments

  • Project.zip
    15.4 KB · Views: 219

Star-Dust

Expert
Licensed User
Longtime User
Sorry I sent an old version by mistake. Now I have renamed it to 0.17. I think you have no problems this way
 

qle

Member
Licensed User
Longtime User
Hi,
Thank you, that fixed the issue.

I now have another problem trying to use SetRowCustomize

If i use
B4X:
     FlexGrid1.SetRowCustomize(0,xui.Color_Blue,xui.Color_LightGray,xui.CreateDefaultFont(14))

I get error java.lang.ClassCastException: anywheresoftware.b4a.objects.ActivityWrapper$AllViewsIterator cannot be cast to android.view.View


Lee.
 

Star-Dust

Expert
Licensed User
Longtime User
I tried your code and it didn't raise the error you report to me. Can you post another example where this error reproduces?

It could be an error with your source, because the error indicates that you are trying to assign a list to a View.
 

qle

Member
Licensed User
Longtime User
Hi,
In the code.. did you un-remark the line?

Lee.
 

Star-Dust

Expert
Licensed User
Longtime User
Update rel 0.18
  1. fixbugs of SetRowCustomize
 

epiCode

Active Member
Licensed User
I was asking if whole table can be set to "read only" with only exception of columns which have checkboxes


I don't understand what it's for. In B4A and B4J you can edit in an enlarged box with the EditCell command

Ability to view full content of a cell by clicking on it (it zooms up) and goes back to normal when clicked elsewhere (focus lost)
 

Star-Dust

Expert
Licensed User
Longtime User
I was asking if whole table can be set to "read only" with only exception of columns which have checkboxes
Basically they are all read-only except the CkecBox.

To make them editable, you must insert the editing activation in the Click or LongClick event with the EditCellonsite or EditCell command. But if you do not enter it all remain read-only

B4X:
Sub FlexGrid1_CellClick(Row As Int, Col As Int)
    If Col=0 Then
        FlexGrid1.SelectRow(Row)
    Else
        Select FlexGrid1.GetTypeCol(Col)
            Case FlexGrid1.TypeInt
                 ' edit cell
                FlexGrid1.EditCellonsite(Row,Col) '   <--------------- Delete this line
            Case FlexGrid1.TypeString
                 ' edit cell
                FlexGrid1.EditCellonsite(Row,Col) '   <--------------- Delete this line
        End Select
    End If
End Sub

or
B4X:
Sub FlexGrid1_CellClick(Row As Int, Col As Int)
         FlexGrid1.SelectRow(Row)
End Sub


Ability to view full content of a cell by clicking on it (it zooms up) and goes back to normal when clicked elsewhere (focus lost)
This function don't exists
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
IMPORTANT UPDATE

Update 0.19
  • Add method AddRowCustomize (Cell As Object(), Text_Color As Int, Background_Color As Int, TextFont As B4XFont, Refresh As Boolean) As String
    Adds a row with custom graphics formatting
  • Add method 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 you set exactly as true it will search for the box that contains exactly that expression if set to false it will check if the expression is contained in the box

Example AddRowCustomize
B4X:
Dim B As boolean = False
For i=11 To 100
   B=Not(B)
   If b Then
       FlexGrid1.AddRowCustomize(Array As Object("B" & i,i,B,"User " & i,Null,Rnd(50,1000)/10),xui.Color_Black,0xFFFFFFFF,xui.CreateDefaultFont(16),True)
   Else
       FlexGrid1.AddRowCustomize(Array As Object("B" & i,i,B,"User " & i,Null,Rnd(50,1000)/10),xui.Color_Black,0xFF44FF44,xui.CreateDefaultFont(16),True)
   End If
Next


Example SearchInColumn
B4X:
Dim rw As Int = FlexGrid1.SearchInColumn("User 10",3,0,True,True)
If rw>-1 Then FlexGrid1.SelectCell(rw,3,False)
Log("Find :" & rw)
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
In the future I plan to insert the following methods:
  • SearchInAllColumn: To search all columns
  • FilterView: To display only the lines that correspond to certain parameters described in the filter, for example display only the lines where there is a certain text
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…