Share My Creation [B4J] MagmaGRID - Next Generation B4XTable 0$

1756831277377.png


What is MAGMAGRID? 🧩


MAGMAGRID is the Next Generation B4XTable... The code for the start is only available to licensed members of the forum.


What can it do? 🔧
Features:

  • Column Resizing ↔
  • Hiding/Showing 👁️
  • Easy Add Column at Creation ➕
  • Easy Inline Editing ✏️
  • Easy Moving ⬍
  • Easy Column Calculation and Sum of Rows ∑
  • Easy Extract Data to List 📋
  • Even if at runtime the window resizes — and B4XTable has different visible rows/columns — it works fine when moving through lines and fields

For now, works only in B4J... but should be easy for B4A too (I think even easier with IME keyboard) 📱


What I expect from all users of Forum:
Add new features and post here their versions or fixes... to create a solid class 💪
Why I didn’t make it a B4XLib... I don’t think B4XTable needs an extra lib with the same features...


But we need to understand how it works and how it can be better 🔍

Uses: B4XTable, InlineEditing, B4XTableSelections, B4XEval

Also I would like to tag some persons that I am sure will help make it better (plz don;t stay at same name of class - you can change it as you want) - but plz post your solution or fix here...
@aeric @PaulMeuris @Mahares @stevel05 @mcqueccu @Mashiane @LucaMs @DonManfred @Alexander Stolte @Star-Dust @Filippo @Peter Simpson @EnriqueGonzalez @asales @Johan Hormaza @tchart @teddybear @TILogistic @JakeBullet70 @Erel

@everyone

ps: I am so sorry for asking (tag you) to add your tips... your ideas... but I believe that if we add from one line from anyone - will have the opportunity to have "business controls" that will help all for Fast Creation of Apps!


The code for the start is only available to licensed members of the forum
You can find it here: https://www.b4x.com/android/forum/t...xt-generation-b4xtable-0.168499/#post-1032789
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Hi Magma, I suggest you create a GitHub repo so it is easier for anyone to make pull request and report issue.
 

Guenter Becker

Active Member
Licensed User
Longtime User
Hi,
I like to use also a Button in a Column. This button is only be used with a click event and icon by font awesome.
Could ypu please give me an snipped how to modify the AddColumn sub.
Tried it in the class code but got always the compiler error that "BUTTON" as type is no accepted type.

Thank you in advance
 

Magma

Expert
Licensed User
Longtime User
Hi,
I like to use also a Button in a Column. This button is only be used with a click event and icon by font awesome.
Could ypu please give me an snipped how to modify the AddColumn sub.
Tried it in the class code but got always the compiler error that "BUTTON" as type is no accepted type.

Thank you in advance
Check GitHub link at 1st post of link attached - for new version: https://www.b4x.com/android/forum/t...xt-generation-b4xtable-0.168499/#post-1032789

Search with your name - and will see the example...

I think callsub is very helpful for this situation... you can do many things !
 

Guenter Becker

Active Member
Licensed User
Longtime User
Ok got it thank you for quick response. I checked it and found we are close to the end. Why?
it works if the button is added as last column.
Moving the AddColumn (Button) up to an other position:

Button as 1st column -example-:
    mg.Initialize(Pane1)
    mg.AddColumn("ShowMoves",  False, True , False,80,"BUTTON","Show Moves...", Array As Object(Me,"showmoves","rowid"),0,0,0,"CENTER",  0, 0, 0, False) 'Asked by Guenter Becker (Anything is different from changing values - must be added as VOID and in DataUpdated) / same for images too
    mg.AddColumn("ID",False,True,True,70,"TEXTFIELD_NUMERIC","",Null, 0,0,0,"CENTER", 5, 0, 0, False)
.....

except the last one like as the 1st column this error is thrown:
LastException:
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Error occurred on line: 171 (MagmaGrid)
java.util.NoSuchElementException
    at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:766)
    at java.base/java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:796)
    at java.base/java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:794)
    at anywheresoftware.b4a.objects.collections.Map$MyMap.getEntry(Map.java:234)
    at anywheresoftware.b4a.objects.collections.Map$MyMap.getValue(Map.java:223)
    at anywheresoftware.b4a.objects.collections.Map.GetValueAt(Map.java:130)
    at b4j.example.magmagrid._setvalue(magmagrid.java:2486)
    at b4j.example.magmagrid._rowcalcpraxis(magmagrid.java:1228)
    at b4j.example.magmagrid._calcall(magmagrid.java:420)
    at b4j.example.magmagrid$ResumableSub_SetData.resume(magmagrid.java:291)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1172)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    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:184)
    at java.base/java.lang.Thread.run(Thread.java:1589)

Don'nt know why. The goal is to put the buutton at any column position.
Any Idea whats goint wrong?
 

Magma

Expert
Licensed User
Longtime User
Ok got it thank you for quick response. I checked it and found we are close to the end. Why?
it works if the button is added as last column.
Moving the AddColumn (Button) up to an other position:

Button as 1st column -example-:
    mg.Initialize(Pane1)
    mg.AddColumn("ShowMoves",  False, True , False,80,"BUTTON","Show Moves...", Array As Object(Me,"showmoves","rowid"),0,0,0,"CENTER",  0, 0, 0, False) 'Asked by Guenter Becker (Anything is different from changing values - must be added as VOID and in DataUpdated) / same for images too
    mg.AddColumn("ID",False,True,True,70,"TEXTFIELD_NUMERIC","",Null, 0,0,0,"CENTER", 5, 0, 0, False)
.....

except the last one like as the 1st column this error is thrown:
LastException:
Waiting for debugger to connect...
Program started.
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Error occurred on line: 171 (MagmaGrid)
java.util.NoSuchElementException
    at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:766)
    at java.base/java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:796)
    at java.base/java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:794)
    at anywheresoftware.b4a.objects.collections.Map$MyMap.getEntry(Map.java:234)
    at anywheresoftware.b4a.objects.collections.Map$MyMap.getValue(Map.java:223)
    at anywheresoftware.b4a.objects.collections.Map.GetValueAt(Map.java:130)
    at b4j.example.magmagrid._setvalue(magmagrid.java:2486)
    at b4j.example.magmagrid._rowcalcpraxis(magmagrid.java:1228)
    at b4j.example.magmagrid._calcall(magmagrid.java:420)
    at b4j.example.magmagrid$ResumableSub_SetData.resume(magmagrid.java:291)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
    at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1172)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    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:184)
    at java.base/java.lang.Thread.run(Thread.java:1589)

Don'nt know why. The goal is to put the buutton at any column position.
Any Idea whats goint wrong?
 

Magma

Expert
Licensed User
Longtime User

Guenter Becker

Active Member
Licensed User
Longtime User
View attachment 166535

What is MAGMAGRID? 🧩


MAGMAGRID is the Next Generation B4XTable... The code for the start is only available to licensed members of the forum.


What can it do? 🔧
Features:

  • Column Resizing ↔
  • Hiding/Showing 👁️
  • Easy Add Column at Creation ➕
  • Easy Inline Editing ✏️
  • Easy Moving ⬍
  • Easy Column Calculation and Sum of Rows ∑
  • Easy Extract Data to List 📋
  • Even if at runtime the window resizes — and B4XTable has different visible rows/columns — it works fine when moving through lines and fields

For now, works only in B4J... but should be easy for B4A too (I think even easier with IME keyboard) 📱


What I expect from all users of Forum:
Add new features and post here their versions or fixes... to create a solid class 💪
Why I didn’t make it a B4XLib... I don’t think B4XTable needs an extra lib with the same features...


But we need to understand how it works and how it can be better 🔍

Uses: B4XTable, InlineEditing, B4XTableSelections, B4XEval

Also I would like to tag some persons that I am sure will help make it better (plz don;t stay at same name of class - you can change it as you want) - but plz post your solution or fix here...
@aeric @PaulMeuris @Mahares @stevel05 @mcqueccu @Mashiane @LucaMs @DonManfred @Alexander Stolte @Star-Dust @Filippo @Peter Simpson @EnriqueGonzalez @asales @Johan Hormaza @tchart @teddybear @TILogistic @JakeBullet70 @Erel

@everyone

ps: I am so sorry for asking (tag you) to add your tips... your ideas... but I believe that if we add from one line from anyone - will have the opportunity to have "business controls" that will help all for Fast Creation of Apps!


The code for the start is only available to licensed members of the forum
You can find it here: https://www.b4x.com/android/forum/t...xt-generation-b4xtable-0.168499/#post-1032789
Hello,
testing the grid this questiones with your example project in B4J 10.3 this questiones came up:

1st
Found this in the internet as result to "how to detect column value change":
Sub mg_ColumnValueChanged(ColumnName As String, NewValue As String)
    Log("Column: " & ColumnName & " changed to: " & NewValue)
    ' Your custom logic here
End Sub
But after changing a textrow's text it does nothing.

2nd
Tried to use:
B4X:
sub useB4XTable_CellClicked(ColumnId as string, RowID as long)
Log(mg.selectedRow & "/" mg.selectedColumn)
end sub
But after clicking in a cell it does nothing.

??? Anything missing, doing wrong or else ???
 

Magma

Expert
Licensed User
Longtime User
Hello,
testing the grid this questiones with your example project in B4J 10.3 this questiones came up:

1st
Found this in the internet as result to "how to detect column value change""how to detect column value change":
Sub mg_ColumnValueChanged(ColumnName As String, NewValue As String)
    Log("Column: " & ColumnName & " changed to: " & NewValue)
    ' Your custom logic here
End Sub
But after changing a textrow's text it does nothing.

2nd
Tried to use:
B4X:
sub useB4XTable_CellClicked(ColumnId as string, RowID as long)
Log(mg.selectedRow & "/" mg.selectedColumn)
end sub
But after clicking in a cell it does nothing.

??? Anything missing, doing wrong or else ???
If you press OK... you are getting all the.. cells...
Check how at button3, (ok)

ps: When you are typing in a cell.. actually not typing into cell but into a control that is placed there...
ps2: unless you mean something different...
 

Guenter Becker

Active Member
Licensed User
Longtime User
If you press OK... you are getting all the.. cells...
Check how at button3, (ok)

ps: When you are typing in a cell.. actually not typing into cell but into a control that is placed there...
ps2: unless you mean something different...

Sorry I belive to know what you are explaining but it does not help me.

But let us shorten the problem. I like to get an information whether the column value has changed either if it is the column itself or an attached control.

Target is to have an own sub in the grid parent that manages the value changes to get the grid in sync with an underlying database for example doing sql update.

The best solution is the shown example above: mg_ColumnValueChanged(ColumnName As String, NewValue As String). But the sub will not be called
May be it is not implemented in your grid or. If not it is an important missing feature. To react on this kinds of events is essential because in most cases one will work with the grid feeded by a database.

Any Idea to solve this need?
 

Magma

Expert
Licensed User
Longtime User
Sorry I belive to know what you are explaining but it does not help me.

But let us shorten the problem. I like to get an information whether the column value has changed either if it is the column itself or an attached control.

Target is to have an own sub in the grid parent that manages the value changes to get the grid in sync with an underlying database for example doing sql update.

The best solution is the shown example above: mg_ColumnValueChanged(ColumnName As String, NewValue As String). But the sub will not be called
May be it is not implemented in your grid or. If not it is an important missing feature. To react on this kinds of events is essential because in most cases one will work with the grid feeded by a database.

Any Idea to solve this need?
This is an approach...

but my approach is to work with grid, and when you complete your work - to Apply/Save it...

This that you asking will make it heavy..
The other side of your approach is the online working the same time with other users (with some limits)

You can fork the project at github and add this option but in my opinion grids should be light. You can have calculations of B4XTable-SQL after leaving cell/control.
 

Guenter Becker

Active Member
Licensed User
Longtime User
This is an approach...

but my approach is to work with grid, and when you complete your work - to Apply/Save it...

This that you asking will make it heavy..
The other side of your approach is the online working the same time with other users (with some limits)

You can fork the project at github and add this option but in my opinion grids should be light. You can have calculations of B4XTable-SQL after leaving cell/control.
The story behind is that I do not want to go over each datarow to examin wether it is changed or not. I like to make changes to the grid column value and by clicking on button i go to insert/update/delete database only for the changed rows.. Anyway played around a little bit with your kindly published code of magmagrid. Did some small modifications and got the prefered solution. Please look at the attached project.
Download from here
 

Magma

Expert
Licensed User
Longtime User
The story behind is that I do not want to go over each datarow to examin wether it is changed or not. I like to make changes to the grid column value and by clicking on button i go to insert/update/delete database only for the changed rows.. Anyway played around a little bit with your kindly published code of magmagrid. Did some small modifications and got the prefered solution. Please look at the attached project.
Download from here
i will check it soon... thanks for sharing (that is the idea here - to make things all together)... credits will be added
 

Magma

Expert
Licensed User
Longtime User
@Guenter Becker ...checking the code... at the map you are saving the object...

a. how this will help ?
b. and how will extract the value ? (you can set the value - but that is when clicking the grid... after changing at control show, you must re-click/select the row/col)
 

Guenter Becker

Active Member
Licensed User
Longtime User
@Guenter Becker ...checking the code... at the map you are saving the object...

a. how this will help ?
b. and how will extract the value ? (you can set the value - but that is when clicking the grid... after changing at control show, you must re-click/select the row/col)
If one clicks in a cell with a checkbos the checkbox checked will change this is captured by CellClick Event.. If one clicks in a cell with an other control and changes the controls value it will be caputred by getUpdatededValue Event. In both cases the rowid column id and column new value of the grid is save to a map (Update_map) done by event triggered sub.
Having a save button then the underlying code will not go over the complete grid rows! It will only inspect if the Update_map wit a loop. Each run takes one updated row information from the map and gets directly the column name and value and uses this information to setup the maps Values and Where used by DBUtils to perform sql insert or update or delete. At the End the content of the update_map is cleared.
The basics of this concept is shown in example project. In my current project I combined the map with a ribbon and my yet not published lib GBEextDBUtils (Work in progress) and DBUtils.

In projects with a small count of database records this way might be not neccessary but if there are a lot of records this way is quicker than to inspect all of the records/rows of a resultset/grid.
 

Magma

Expert
Licensed User
Longtime User
ok i got the idea when selecting grid row getting value...

but when someone is focused at a control on grid (edittext) and not select other col/row... the map will never get the new value... in those cases need a timer / loop saving-update map

it is useful but the same time dangerous.. need some thinking 🤔
 

Guenter Becker

Active Member
Licensed User
Longtime User
ok i got the idea when selecting grid row getting value...

but when someone is focused at a control on grid (edittext) and not select other col/row... the map will never get the new value... in those cases need a timer / loop saving-update map

it is useful but the same time dangerous.. need some thinking 🤔
youre right, But I think it's easy to explain to the user that he has to confirm finishing the edit/input by clicking on another column,
In this case the click event of the other column will be fired but except it' s checkbox column nothing else is done in the vent sub. So it doens'nt matter.
 
Top