Is therer an elegant and generic solution for Java...
# compose-desktop
m
Is therer an elegant and generic solution for JavaFX like TableViews in Compose Desktop?
z
m
It's worth a try, but I thought of a JavaFX like Table component with a nice api to display entities directly, edit those, sort them, make selections and so an
s
What would that look with a declarative API? I wrote https://github.com/sproctor/compose-data-table a while ago. I'm going to add select/sort functions eventually. The hardest part is imagining what the API for it should look like.
m
Hey, I tried out your component and it suits perfectly! There's just one thing I'm missing right now, which is the ability to scroll through a table. If the window's small, not every row fits on the screen, I have to chance to see the rows outside of my screen. Is there a way to enable scrolling on a DataTable @Sean Proctor? BW.
s
You can use
Modifier.verticalScroll()
m
Wouldn't that enable scroll on the whole table indlucding the headlines?
s
There's currently no way to have sticky headers/footers. It's a feature that I need for my app. I'm going to try to add it soon.
m
Would it be possible to just kindof make two Columns (one normal one lazy) and have something like this Column { Headline() LazyColumn { items(rows) { ... } } } and just give the scrollable modifier to the inner lazy column?
s
Everything needs to be in the same Composable to be measured. It's currently not lazy at all. All of the cells need to be measured to properly set the width of the columns.
There's a few other existing solutions. I'm going to look through them and see if they have a clever way to handle this. My plan is to make it always scrollable (like LazyColumn), allow a scroll state to be passed in, and always make header and footer sticky. Someone could still put it in another scrollable Composable if they don't want sticky headers/footers.
m
Sounds nice!
Another quick question... is there a way to make something like a rowspan? So one cell occupies 2 rows?
s
No, what's the use case?
My plan is to implement the material spec. There's no spec for material3, so that part is extrapolation of the m2 spec. The purpose is to be able to display data in a readable form, not to make a general purpose table. Allowing cells to span multiple columns makes the column width calculations much more complicated.
m
I am using the DataTable component (among others) for displaying a duty roster, in which every row has its timespan (first row 08:00 - 09:00, second row from 09:00 - 10:00 and so on). Some shifts however are longer than one row would allow (e.g. from 08:00 - 10:00) . To address this I would've used something like a rowspan, although I know that this might not be the optimal use-case for a DataTable, I wanted to give it a shot 😄
This component had lots of "Table-Like" features so I wanted to use your DataTable for it 😄
s
Sorry, I haven't finished my coffee yet. That wouldn't make column width calculations more complicated, I was thinking of a column span. Let me think about it for a minute.
I don't know what happens to the overflow here. I think the height of the rows is set to 52 dp. You could try to make the content 104 dp for the cell in the first row. It might get clipped or make the row bigger, or maybe it will work.
m
The content is already at maxHeight. Making it even bigger does not change anything
It seems to be restricted in order to not overflow xD
s
I don't see anything for compose that supports a row span like that. If your cells are fixed size (or propotional, just not based on content), you could make a custom thing using `Column`s that wouldn't be too difficult.
I haven't used it, but lazy table (mentioned above) says it supports row spans.