B4J Library jTableViewExtended

This library extends TableView and provides more control on the columns, rows and cells.

What you get with TableView:

before.jpg


What you can get with TableViewExtended (with the same data):

after.jpg


You can easily enhance an existing TableView by initializing your TableViewExtended with InitializeByExtending(MyExistingTableView).

Changelog:
v1.0:
- I added the TableRow class;
- I added ClearSelection, DisableReorderingColumns, FixedCellHeight, MultipleSelection, Placeholder, SelectedCells, SelectedRows, SetRowEventsListener, Sort and SortOrder to TableViewExtended;
- I replaced RowIndex and RowStyle by Row in TableCell;
- I modified the example to open a message box on double-click on a row.

v1.1:
- I added the Column property to the TableCell class.

v1.11:
- I fixed an issue with OpenJDK 11 in the DisableReorderingColumns function.
 

Attachments

  • jTableViewExtended_111.zip
    47.7 KB · Views: 637
Last edited:

Pravin Shah

Member
Licensed User
Longtime User
Thanks @Informatix for the extended TableView code with extra features.... It is really nice.

Is it possible to show tableview with expandable records, I mean showing child records under parent records with parent record can be expanded or collapsed?
 

Pravin Shah

Member
Licensed User
Longtime User

Informatix

Expert
Licensed User
Longtime User
While searching further on this topic, I found following youtube video which demonstrates Expandable Tableview capability, this really looks nice and will be very helpful in most of the projects. I believe it is written in Java and being non-java guy, I am not sure how to port it in B4J. If @Erel or anyone could help over here to build a library.

Thanks in advance.


https://controlsfx.bitbucket.io/org/controlsfx/control/table/TableRowExpanderColumn.html?
The code that you see in the video is not in Java. Anyway, doing the same thing requires to wrap the ControlsFX.TableRowExpanderColumn class first. So, unless someone has some time to wrap and share it, there's no easy solution for now.
 

rboeck

Well-Known Member
Licensed User
Longtime User
I tried your example and now i have two questions: whats the standard way for static formating of columnheader? Are css styles the only way?
Is your Expandable Tableview also useable for customized row formating and if yes, can you make some hints?

Thanks in advance.
 

Informatix

Expert
Licensed User
Longtime User
I tried your example and now i have two questions: whats the standard way for static formating of columnheader? Are css styles the only way?
You have to use a CSS file or the Style property for the column headers (note that the Style property value is applied to all cells of the column).
Is your Expandable Tableview also useable for customized row formating and if yes, can you make some hints?
Look at the demo. It shows how to format cells (CellFactory) and rows (Cell.Row.Style=...).
 

Pravin Shah

Member
Licensed User
Longtime User
The code that you see in the video is not in Java. Anyway, doing the same thing requires to wrap the ControlsFX.TableRowExpanderColumn class first. So, unless someone has some time to wrap and share it, there's no easy solution for now.

Sure, I understand.. I will wait till then :):).. Thanks..
 

Fabrice La

Active Member
Licensed User
Longtime User
Hi,

I would like to use this tveCities.SelectedCells(). But I don't know how ? I need to use it to retrieve the cell data.
Thanks
 

Informatix

Expert
Licensed User
Longtime User
Hi,

I would like to use this tveCities.SelectedCells(). But I don't know how ? I need to use it to retrieve the cell data.
Thanks
From the documentation:
"Returns a two-dimensional array containing the position (row, column) of selected cells."

It's an array inside an array. It's not obvious indeed:
B4X:
Dim C(,) As Int = tveCities.SelectedCells
For i = 0 To C.Length - 1
       Log("Row = " & C(i, 0) & " / Col = " & C(i, 1))
Next
 
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User

BarryW

Active Member
Licensed User
Longtime User
How to trigger the edit function without double clicking the cell (tablecell = sender).

I'am trying to make it using keypress of enter or F2.

I'am now successfully getting the keypress event of tableview and my problem is how to trigger the edit event.

Just like this

B4X:
    Dim C(,) As Int = tveCities.SelectedCells
    If C.Length >= 1 Then
        Log("row: " & C(0,0))
        Log("col: " & C(0,1))

        Dim tablecell As TableCell = c
        'proceed to edit cell
    End
 

Informatix

Expert
Licensed User
Longtime User
How to trigger the edit function without double clicking the cell (tablecell = sender).

I'am trying to make it using keypress of enter or F2.

I'am now successfully getting the keypress event of tableview and my problem is how to trigger the edit event.

Just like this

B4X:
    Dim C(,) As Int = tveCities.SelectedCells
    If C.Length >= 1 Then
        Log("row: " & C(0,0))
        Log("col: " & C(0,1))

        Dim tablecell As TableCell = c
        'proceed to edit cell
    End
In the demo, you should copy the code from MousePressed:
B4X:
'Marks the cell and raises a CellFactory event to replace the text of the city name by a TextField
EditedCell = Cell
EditedCell.Tag = Cell.Row.Index
Cell.Update

'Sets the focus on the editor (requires to consume the event first)
EventData.Consume
tfEditor.RequestFocus
 

BarryW

Active Member
Licensed User
Longtime User
How to set value for cell?

EditedCell = Cell -> where this value came from without clicking.
 

BarryW

Active Member
Licensed User
Longtime User
Sorry but i think you dont understand what i am asking.

ok let me breakdown it.

to edit a cell you need to double click it and convert the cell to a textfield.

what do i want is to make it editable without double clicking it.

tnx
 
Top