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

Star-Dust

Expert
Licensed User
Longtime User
Update 0.26
  • Fix bug.
    Fixed a bug when switching focus from one editable box to another
 

Oscarin

Member
for what purpose?
Thanks for the reply.

I have a product list on the bottom (using the library) and on the top all the product information I want the user to double-click on the grid to be able to edit the product information on the top and not on the grid itself and I try not use the click option to avoid mistakes when scrolling thought the list.
 

Star-Dust

Expert
Licensed User
Longtime User
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)
 

Oscarin

Member
Update 0.26
  • Fix bug.
    Fixed a bug when switching focus from one editable box to another
I get an error with this update when using
FlexGrid1.ClearRows
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.get(ArrayList.java:437)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example.flexgrid._selectviewer(flexgrid.java:2456)
at b4a.example.flexgrid$ResumableSub_CreateGrid.resume(flexgrid.java:938)
at b4a.example.flexgrid._creategrid(flexgrid.java:798)
at b4a.example.flexgrid._invalidate(flexgrid.java:1919)
at b4a.example.flexgrid._clearrows(flexgrid.java:495)
at b4a.example.principal$ResumableSub_B4XPage_CloseRequest.resume(principal.java:199)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
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 anywheresoftware.b4a.BA.raiseEvent(BA.java:193)

PS
I do have lines of data on the FlexGrid
 

Star-Dust

Expert
Licensed User
Longtime User
Can you produce an example that produces the error? Why doesn't it return this error to me in my applications.
 

Oscarin

Member
Can you produce an example that produces the error? Why doesn't it return this error to me in my applications.
This is what I got in the sub

Sub B4XPage_CloseRequest As ResumableSub
If ListView1.Visible Then
ListView1.Clear
ListView1.Visible=False
Return False
End If
Dim sf As Object = xui.Msgbox2Async("¿Desea cerrar Sesión?", "", "Si", "", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
FlexGrid1.ClearRows
Return True
End If
Return False
End Sub

Then on the logs I get
Error occurred on line: 74 (Principal)
Line 74 is
FlexGrid1.ClearRows
 

Star-Dust

Expert
Licensed User
Longtime User
I asked you for an example not the code, this means creating a small project that has this problem so that it can Debug.

In any case, it is not the ClearRows that produces the error, looking at the error it seems that you are simultaneously clearing you are doing a refresh of the grid or you are accessing the rows of the grid.

In the error I need to see the part starting from 'CAUSATED BY' so that the SUB that generates it is identified
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.27
  • added properties ScrollX and ScrollY
  • Added events ScrollX() and ScrollY()
 
Last edited:

Oscarin

Member
I've found what causes the error, I don't know if it is a bug or just bad programming (I don't remember from where I copied)
In my app, the user adds lines with descriptions and qty to the grid
When the user add something that is already on the grid, I add the qty to the one is already there, and I had this lines on my code
FlexGrid1.ScrollToRow=Row
FlexGrid1.SelectRow(Row)
FlexGrid1.SetCellValue(Row,2,que_cantidad)

When the user exited the app and called the
FlexGrid1.ClearRows
is when I get the error.
To fix the problem, I removed the
FlexGrid1.ScrollToRow=Row
FlexGrid1.SelectRow(Row)
And I don't get the error anymore
 

Star-Dust

Expert
Licensed User
Longtime User
I think it's a bug, I'll try to fix it in the next update
 

Oscarin

Member
Is there a way to have an automatic with of the columns?
Let's say that I have 2 columns with smaller than the width of the screen and I anchor the grid on to both sides of the screen, the grid will fill the width but I'll have a gray empty area because the width of the columns are smaller than the width of the screen
 

amorosik

Expert
Licensed User
Congratulations for the library, the closest available for the B4X environments of the famous TrueGrid
I'm trying the example for B4J, how to change the sort order according to column 3, or 2, etc?
I'm talking about what you basically do with the various dbgrids by clicking on the column title
Or to change the order, the only way is to modify the select sql?
 

Star-Dust

Expert
Licensed User
Longtime User
NEW EXAMPLE.
In FlexGrid we can have a fixed line at the top of the grid.
How to get a fixed row at the bottom of the row, similar to a column total?How to get a fixed Column on the left of the Table?
Attached is a cross-platform example that illustrates how to achieve these particular effects with a little more code.

NB. You no longer need to follow this example to freeze the grid foot row. See update 0.34


 

Attachments

  • Sample4.zip
    25.1 KB · Views: 229
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
In testing the function that sorts by column.
But I am not sure that I will publish it because I am thinking of creating a new library for grids with more functions

B4X:
Sub FlexGrid1_HeadClick(Index As Int)
    Log("Click Head Col: " & Index)
    FlexGrid1.SortForCol(Index)
End Sub

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…