B4J Question SDFlexGrid Error on RemoveRow

DarkoT

Active Member
Licensed User
Hi to all,
need help... I implemented new functionality to my App with SD_FLEXGRID library... As I'm know, it's not possible to clear grid with routine (FlexGrid1.ClearGrid or similar). I need to go with For next loop and remove row inside of loop:

RemoveRow:
For x = 1 To tblOpenWo.RowCount - 1
    tblOpenWo.RemoveRow(x)
Next

(I hope this will be done for 1000 rec in sec)... but - for this code i received a error!

Waiting for debugger to connect...
Program started.
Thu Jun 17 16:04:28 CEST 2021 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Error occurred on line: 222
java.lang.IndexOutOfBoundsException: Index 1158 out of bounds for length 1158
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:458)
at javafx.base/com.sun.javafx.collections.ObservableListWrapper.get(ObservableListWrapper.java:89)
at javafx.base/com.sun.javafx.collections.VetoableListDecorator.get(VetoableListDecorator.java:306)
at anywheresoftware.b4j.objects.PaneWrapper.Get(PaneWrapper.java:386)
at b4j.example.flexgrid._deleterow(flexgrid.java:955)
at b4j.example.flexgrid._removerow(flexgrid.java:1741)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:676)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:240)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:64)
at b4j.example.b4xmainpage._refreshgrid(b4xmainpage.java:356)
at b4j.example.b4xmainpage._tptabi_tabchanged(b4xmainpage.java:758)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:108)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA$1.run(BA.java:233)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

any help? What I'm doing wrong?

Regards,
DaT
 

Star-Dust

Expert
Licensed User
Longtime User
it's not possible to clear grid with routine
You are wrong
B4X:
tblOpenWo.ClearRows
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
In any case the code is wrong because by exceeding half the grid you go to delete lines that do not exist because as it deletes the number of lines of grid, so the correct code would be like this

B4X:
For x =tblOpenWo.RowCount - 1 to 0 Step-1
    tblOpenWo.RemoveRow(x)
Next

Or so

B4X:
For x =0 to tblOpenWo.RowCount - 1
    tblOpenWo.RemoveRow(0)
Next
 
Last edited:
Upvote 0

DarkoT

Active Member
Licensed User
In any case the code is wrong because by exceeding half the grid you go to delete lines that do not exist because as it deletes the number of lines of grid, so the correct code would be like this

B4X:
For x =tblOpenWo.RowCount - 1 to 0 Step-1
    tblOpenWo.RemoveRow(x)
Next

Or so

B4X:
For x =0 to tblOpenWo.RowCount - 1
    tblOpenWo.RemoveRow(0)
Next
No, sorry, will not work... The system give me always a error when I want to remove a row from existing grid... I think here should be a error in library... In any case - I have question about "initialling" a grid... What will be your suggestion how to clear already presented data in grid and full fill grid with new data?
(When I use B4XGrid it's really simple - tbl.clear and go to full fill a grid with new data...)

Tnx, DaT
 
Upvote 0

DarkoT

Active Member
Licensed User
Which version are you using?
Library version 0.13:

2021-06-18_08h39_29.png
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I need to check, maybe there's an error in the library release. It is probably an older version with the 0.13 mark.
In the afternoon I'm in the office to do the checks

Also check if the tblOpenWo.ClearRow method exists (without the "s").
 
Upvote 0

DarkoT

Active Member
Licensed User
I need to check, maybe there's an error in the library release. It is probably an older version with the 0.13 mark.
In the afternoon I'm in the office to do the checks

Also check if the tblOpenWo.ClearRow method exists (without the "s").
Thank you @Star-Dust;method .ClearRow exists (for info). If you can check, I will be very greatfull... Thank you in advance; if you need aditional information, just contact me...
Btw - FlexGrid is nice, I'm start using this grid while give me possibility to have INTABLE EDIT (inline editing)... Work nice, great job from your site...
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Thank you @Star-Dust;method .ClearRow exists (for info). If you can check, I will be very greatfull... Thank you in advance; if you need aditional information, just contact me...
Btw - FlexGrid is nice, I'm start using this grid while give me possibility to have INTABLE EDIT (inline editing)... Work nice, great job from your site...
As I imagined I am working with an undistributed version and the method has changed its name in this version that I use.

I'll be releasing the updates in the afternoon. I'll post an example of the removeRow command
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Thank you @Star-Dust;method .ClearRow exists (for info). If you can check, I will be very greatfull... Thank you in advance; if you need aditional information, just contact me...
Btw - FlexGrid is nice, I'm start using this grid while give me possibility to have INTABLE EDIT (inline editing)... Work nice, great job from your site...
Release ver. 0.14. Try It
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
@Star-Dust - you are my man... :) Thank you... It's working... Nice job...

Suggestion: Add search field to grid, will be more as useful ;)
Already it was pointed out to me but I didn't have time to implement.
 
Upvote 0
Top