Can you load the columns in reverse order and freeze the left? Not all data would support this arrangement but just a thought.Is there a simple way to set the FrozenColumns at the right side of B4XTable instead of left?
I am not sure what you mean. A sample code would help.Can you load the columns in reverse order and freeze the left? Not all data would support this arrangement but just a thought.
Instead of loading the columns in order of 1,2,3...9 load them as 9,8,7...1. It depends on what your data looks like, it may not make sense to order it like that.I am not sure what you mean. A sample code would help.
s there a simple way to set the FrozenColumns at the right side of B4XTable instead of left?
Instead of loading the columns in order of 1,2,3...9 load them as 9,8,7...1
If John's and Ted's suggestion suits you and does not make things worse, here is the code you need to reverse the order of the columns and freeze:He meant that you can arrange the columns at right to the left
For i= B4XTable1.Columns.Size-1 To 0 Step -1
Dim c As B4XTableColumn = B4XTable1.Columns.Get(i)
' Log(c.Id)
B4XTable1.VisibleColumns.RemoveAt(B4XTable1.VisibleColumns.IndexOf(c))
B4XTable1.VisibleColumns.InsertAt(B4XTable1.Columns.Size-1, c)
Next
B4XTable1.Refresh
B4XTable1.NumberOfFrozenColumns = 2
Any comment on post #6. It is uncharacteristic of you not to fully address your thread till the end. Otherwise, we like to see how you solved it.A sample code would help
I think an easier way to do this would be to reverse the order of your sql statement.If John's and Ted's suggestion suits you and does not make things worse, here is the code you need to reverse the order of the columns and freeze:
B4X:For i= B4XTable1.Columns.Size-1 To 0 Step -1 Dim c As B4XTableColumn = B4XTable1.Columns.Get(i) ' Log(c.Id) B4XTable1.VisibleColumns.RemoveAt(B4XTable1.VisibleColumns.IndexOf(c)) B4XTable1.VisibleColumns.InsertAt(B4XTable1.Columns.Size-1, c) Next B4XTable1.Refresh B4XTable1.NumberOfFrozenColumns = 2
Sorry, I was busy with other stuff.Any comment on post #6. It is uncharacteristic of you not to fully address your thread till the end. Otherwise, we like to see how you solved it.
The code I inserted freezes the columns on the left only and it is placed after the table is loaded with the list data in the normal way: B4XTable1.SetData(data). You have added it correctly in your project. It appears that the code does not address what you want, if you want to freeze the right columns. I thought perhaps it is something you want as a temporary data view without having to create a new SQL select query to reverse the order of the columns. Please request that Erel sees this thread and he may have the solution you want. I am going to play with your project a little more anay way as it is interesting.As you can see from the illustration below, the Frozen Columns are still at the left side.
The reason for my code is it runs faster than having to recreate the entire select query becayuse it only changes the visible page data at a time and you do not have to clear the table.Instead of saying select cola,colb,colc from sometable
say select colc,colb,cola from sometable
As you can see from the illustration below, the Frozen Columns are still at the left side. I know I can show the columns by adding them in my preferred order but I want to freeze the last column so it cannot be scrolled.
View attachment 139871
Yes, this is what I am trying to do.add a parm to indicate left or right
Public ShowFrozenColumnAtRight As Boolean
If ShowFrozenColumnAtRight Then
IsFrozen = ColumnIndex > VisibleColumns.Size - NumberOfFrozenColumns
Else
IsFrozen = ColumnIndex < NumberOfFrozenColumns
End If
RemoveColumnFromCLV(c)
clvData.InsertAt(CLVIndex, c.Panel, c)
#if B4J
Dim offset As Float = 1
#else
Dim offset As Float = 0
#end if
c.Panel.SetLayoutAnimated(0, offset + FreezedWidth, clvData.AsView.Top + offset, c.ComputedWidth, clvData.AsView.Height)
Don't give up, you are so close to getting this. Is it possible to not allow the user to resize this particular form?
Dim i As Int = NumberOfFrozenColumns
Do While i < VisibleColumns.Size
Dim i As Int
Dim ColMax As Int
if (FreezeRight) then ' some boolean to denote you freeze right cols
i = 0
ColMax = VisibleColumns.Size - NumberOfFrozenColumns
Else
i = NumberOfFrozenColumns
ColMax = VisibleColumns.Size
End If
Do While i < ColMax
...
Public Sub Main_Resize
' reposition the Edit column
B4XTable1.GetColumn("Edit").Panel.Left = B4XTable1.clvData.AsView.Left + B4XTable1.clvData.AsView.Width
' adjust width of the last column when resizing to the right
' -3 => column1 removed, edit column, index start at 0
B4XTable1.clvData.ResizeItem(B4XTable1.Columns.Size-3, B4XTable1.GetColumn("Column A").Panel.Width)
End Sub
#AdditionalJar: sqlite-jdbc-3.7.2
Private Sub ResizeAndReorderCLVItems
...
Main.Main_Resize
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("1")
MainForm.Show
'MainForm.Resizable = False
Nice, works great!Starting from your FrozenColumnsDemo2.zip i managed to find a solution to your problem with the B4XTable frozen right column.
In the Main module i added this code:
I switched to the SQLite library that is on my computer:B4J Main module:Public Sub Main_Resize ' reposition the Edit column B4XTable1.GetColumn("Edit").Panel.Left = B4XTable1.clvData.AsView.Left + B4XTable1.clvData.AsView.Width ' adjust width of the last column when resizing to the right ' -3 => column1 removed, edit column, index start at 0 B4XTable1.clvData.ResizeItem(B4XTable1.Columns.Size-3, B4XTable1.GetColumn("Column A").Panel.Width) End Sub
And in the B4XTable class i added a call to the subroutine Main_Resize at the end of the subroutine ResizeAndReorderCLVItems:B4X:#AdditionalJar: sqlite-jdbc-3.7.2
This is the result when resizing the form to the right:B4X:Private Sub ResizeAndReorderCLVItems ... Main.Main_Resize End Sub
View attachment 139921
And this is how it looks when resizing to the left:
View attachment 139922
Note: i have only tested this in B4J.
In the attached zip-file you can find my version based on your work (and the other contributors to this thread).
Happy coding!
P.S. you can block the resizing with this code (uncomment the line #5):
B4X:Sub AppStart (Form1 As Form, Args() As String) MainForm = Form1 MainForm.RootPane.LoadLayout("1") MainForm.Show 'MainForm.Resizable = False
code
Public Sub Main_Resize
' reposition the Edit column
B4XTable1.GetColumn("Edit").Panel.Left = B4XTable1.clvData.AsView.Left + B4XTable1.clvData.AsView.Width
' adjust width of the last column when resizing to the right
' -3 => column1 removed, edit column, index start at 0
B4XTable1.clvData.ResizeItem(B4XTable1.Columns.Size-3, B4XTable1.GetColumn("Column A").Panel.Width)
End Sub