A Agnetha Member Licensed User Longtime User Jul 3, 2024 #1 Hello! I have to set the column positions in TableView (NOT B4x Table) programmaticly, e.g. Col3, Col0, Col1, Col2. How can i do that programmaticly ? Thank you!
Hello! I have to set the column positions in TableView (NOT B4x Table) programmaticly, e.g. Col3, Col0, Col1, Col2. How can i do that programmaticly ? Thank you!
DarkoT Active Member Licensed User Longtime User Jul 4, 2024 #2 Hi, please, take a look on this example... If you will need help, let me know... DatTable - extension of B4XTable Hi to all, Based on the B4XTable library, I have made a small enhancement that is extremely practical for the user. It enables three additional functionalities: a) Reordering of row sequence and column lengths b) Resetting the saved layout (to default layout) c) Exporting data to Excel The... www.b4x.com With small modification you can use the same logic with a TableView... Or I can prepare example which will help you to create end solution... Upvote 0
Hi, please, take a look on this example... If you will need help, let me know... DatTable - extension of B4XTable Hi to all, Based on the B4XTable library, I have made a small enhancement that is extremely practical for the user. It enables three additional functionalities: a) Reordering of row sequence and column lengths b) Resetting the saved layout (to default layout) c) Exporting data to Excel The... www.b4x.com With small modification you can use the same logic with a TableView... Or I can prepare example which will help you to create end solution...
mangojack Expert Licensed User Longtime User Jul 4, 2024 #3 Based on @Erels example Here ... which saves the column order on app close ... (when user manually reorders columns). I have slightly modified the code to also programmatically reorder the columns and again save the order for next app run. In the example this is done via Button click , and in a set new order, so you will have to think of an alternative way to work in with your app. But it should give you a good insight how you might be able to solve your issue. Attachments TableExampleColumnSort.zip TableExampleColumnSort.zip 3.5 KB · Views: 429 Upvote 0
Based on @Erels example Here ... which saves the column order on app close ... (when user manually reorders columns). I have slightly modified the code to also programmatically reorder the columns and again save the order for next app run. In the example this is done via Button click , and in a set new order, so you will have to think of an alternative way to work in with your app. But it should give you a good insight how you might be able to solve your issue.
DarkoT Active Member Licensed User Longtime User Jul 4, 2024 #4 Agnetha said: Hello! I have to set the column positions in TableView (NOT B4x Table) programmaticly, e.g. Col3, Col0, Col1, Col2. How can i do that programmaticly ? Thank you! Click to expand... Or - maybe this will help you... If you need example, I can share this source to you... Upvote 0
Agnetha said: Hello! I have to set the column positions in TableView (NOT B4x Table) programmaticly, e.g. Col3, Col0, Col1, Col2. How can i do that programmaticly ? Thank you! Click to expand... Or - maybe this will help you... If you need example, I can share this source to you...
mangojack Expert Licensed User Longtime User Jul 4, 2024 #5 @DarkoT .. the OP is wishing to sort the columns programmatically. Upvote 0
DarkoT Active Member Licensed User Longtime User Jul 4, 2024 #6 mangojack said: @DarkoT .. the OP is wishing to sort the columns programmatically. Click to expand... Ah, right... I obviously missed that requirement... but - the basic idea is still included in the solution (as a starting point).... Upvote 0
mangojack said: @DarkoT .. the OP is wishing to sort the columns programmatically. Click to expand... Ah, right... I obviously missed that requirement... but - the basic idea is still included in the solution (as a starting point)....
Daestrum Expert Licensed User Longtime User Jul 8, 2024 #8 This should do what you want ( in inline java ) Call it with Code: Copy ' put cols in order 2,0,1 - with some bad column numbers added too Me.as(JavaObject).RunMethod("orderOfCols",Array(TableView1,Array As Int(2,-3,0,1,9))) Code: Copy #if java import javafx.scene.control.TableView; import javafx.scene.control.TableColumn; public static void orderOfCols(TableView tv,int[] order){ // number of columns in table int colcnt = tv.getColumns().size(); // dimension our saved columns TableColumn[] cols = new TableColumn[colcnt]; // grab original columns for (int a = 0 ; a< colcnt; a++){ cols[a] = (TableColumn)tv.getColumns().get(a); } // clear the columns in the tableview tv.getColumns().clear(); // insert our saved columns back into tableview in the order we want for (int aaa : order){ // check for valid columns if (aaa >colcnt || aaa < 0) continue; tv.getColumns().add(cols[aaa]); } } #End If Upvote 0
This should do what you want ( in inline java ) Call it with Code: Copy ' put cols in order 2,0,1 - with some bad column numbers added too Me.as(JavaObject).RunMethod("orderOfCols",Array(TableView1,Array As Int(2,-3,0,1,9))) Code: Copy #if java import javafx.scene.control.TableView; import javafx.scene.control.TableColumn; public static void orderOfCols(TableView tv,int[] order){ // number of columns in table int colcnt = tv.getColumns().size(); // dimension our saved columns TableColumn[] cols = new TableColumn[colcnt]; // grab original columns for (int a = 0 ; a< colcnt; a++){ cols[a] = (TableColumn)tv.getColumns().get(a); } // clear the columns in the tableview tv.getColumns().clear(); // insert our saved columns back into tableview in the order we want for (int aaa : order){ // check for valid columns if (aaa >colcnt || aaa < 0) continue; tv.getColumns().add(cols[aaa]); } } #End If