Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Designing in TableViews #176

Closed
SaadSidd29 opened this issue Apr 14, 2022 · 20 comments
Closed

Designing in TableViews #176

SaadSidd29 opened this issue Apr 14, 2022 · 20 comments
Labels
not an issue Everything that is not an issue

Comments

@SaadSidd29
Copy link

Hi,

I cannot see any MFXTableViews in my scene builder with version MFX 11.13.5. I can only see MFXLegacyTableView
Also is there any documentation on how to make tables as it has no columns and I need to have columns and filters.
Please look into the image for all elements I am having

Thanks,
Saad

image

@SaadSidd29
Copy link
Author

SaadSidd29 commented Apr 14, 2022

Ok, I got it, I have now added VirtualizedFX, and it's there :)

Do you have any documentation on how to add rows to the table because I need to fetch the database into this table
also, I cannot do

nameCol.setCellValueFactory(new PropertyValueFactory<>("name"));

@Threepwood98
Copy link

I have exactly the same problem, I don't know how to add columns to the mfxtableview

@SaadSidd29
Copy link
Author

@kdelgado98 If you want to add columns then you can do something like this.

mfxtable is your table name.

MFXTableColumn firstName = new MFXTableColumn("FirstName"); MFXTableColumn lastName = new MFXTableColumn("LastName"); mfxtable.getTableColumns().add(firstName); mfxtable.getTableColumns().add(lastName);

I am having an issue with the data population.
Not able to map with setCellValueFactory

@palexdev Need your urgent advisory

Thanks,
Saad

@palexdev
Copy link
Owner

palexdev commented Apr 16, 2022

I'm sorry, this week has been crazy I've been busy the whole time.

So, configuring MFXTableView is pretty easy.
Let's say my model is a Person with name, age and career.

First you have to create the MFXTableColumns you need

MFXTableColumn<Person> nameColumn = new MFXTableColumn<>("Name");
MFXTableColumn<Person> ageColumn = new MFXTableColumn<>("Age");
MFXTableColumn<Person> careerColumn = new MFXTableColumn<>("Career");

Then you must tell the columns how to represent the data, how to create the corresponding cells so:

nameColumn.setRowCellFactory(person -> new MFXTableRowCell(Person::getName));
ageColumn.setRowCellFactory(person -> new MFXTableRowCell(Person::getAge));
careerColumn.setRowCellFactory(person -> new MFXTableRowCell(Person::getCareer));

That's it, now the two remaining steps is to add the columns to the table so:

table.getTableColumns().addAll(nameColumn, ageColumn, careerColumn);

And add the items to the table:

table.setItems(people);
OR
table.getItems().setAll(people);

A full example is here in the demo: TableViewsController.java

Edit: Note that MFXTableColumn also has other constructors, as well as MFXTableRowCell (to specify how to convert the data to a String)

@palexdev palexdev added the not an issue Everything that is not an issue label Apr 16, 2022
@SaadSidd29
Copy link
Author

@palexdev Thanks so much ...
Yeah, I can understand, same here with me.

Will try this :)

Thanks,
Saad

@palexdev
Copy link
Owner

@SaadSidd29 no problem, thanks for using MaterialFX ;)

I'll leave the issue open for a bit so if you encounter any other problem let me now and I'll answer asap

@SaadSidd29
Copy link
Author

Sure Thanks :)

@SaadSidd29
Copy link
Author

Great! I have done it 👍
Filters are looking amazing. Great Work

Hats off bro :)

Leaving this open for @kdelgado98 If you need any help you can ask here or can contact me

@palexdev
Copy link
Owner

Great! I have done it 👍
Filters are looking amazing. Great Work

Hats off bro :)

Leaving this open for @kdelgado98 If you need any help you can ask here or can contact me

Thanks
Well to be fair the table still needs some adjustments on the layout side, scrollbars need to be properly fixed but it's the next thing I'm gonna do, I'm working on it right now

@SaadSidd29
Copy link
Author

Can you advice me on how to make a specific row of a table highlighted when a button is pressed.
I have been trying to do this on normal TreeTableView but no luck.

Functionality refers to requirement that when a row is being read and processed, it should be marked as RED and rest GREEN.

@palexdev
Copy link
Owner

Well there are several ways you could achieve this
Two come to my mind:

  1. The easiest one in my opinion if you don't care about selection. You could use the selection state of the rows to indicate the state. Selected -> Being processed, Not selected -> Not processed. When you take an item that needs to be processed use the table' selection model to select the item. Of course you need a stylesheet to customize the colors. Default background would be RED and when selected GREEN
  2. This is more tricky and requires more code and knowledge. You could design custom MFXTableRows and create new PseudoClasses specifically for your task, so maybe ":processing" and then of course a stylesheet

@mahfoud09
Copy link

can i setGraphic in cell MFXPaginatedTableView (for exemple : MFXButton ) ?

@palexdev
Copy link
Owner

can i setGraphic in cell MFXPaginatedTableView (for exemple : MFXButton ) ?

Read the documentation MFXTableRowCell
MaterialFX documentation is gold compared to most libraries out there
I'm not a teacher guys you must learn just like I did ;)

Sidenote: this issue will be closed by the end of the week since there hasn't been any useful feedback in the last few days

@Threepwood98
Copy link

Great! I have done it 👍 Filters are looking amazing. Great Work

Hats off bro :)

Leaving this open for @kdelgado98 If you need any help you can ask here or can contact me

Thanks i've been too busy this week but thanks for leave this open for me 😅, i will work on it asap and if i have any trouble i will contact you , thanks again

@mahfoud09
Copy link

thanks @palexdev
one more question , item not updated when page changed in MFXPaginatedTableView

@palexdev
Copy link
Owner

thanks @palexdev
one more question , item not updated when page changed in MFXPaginatedTableView

Share a minimal reproducible example please so that I can test it
It could depend from various things

@mahfoud09
Copy link

thanks @palexdev
one more question , item not updated when page changed in MFXPaginatedTableView

Share a minimal reproducible example please so that I can test it It could depend from various things

i have a table of products and i put a tooltip on each row
when i change the page the product change only on tableview but the real product not changed

image
image

@palexdev
Copy link
Owner

thanks @palexdev
one more question , item not updated when page changed in MFXPaginatedTableView

Share a minimal reproducible example please so that I can test it It could depend from various things

i have a table of products and i put a tooltip on each row when i change the page the product change only on tableview but the real product not changed

image image

I don't think it's related to MaterialFX, it depends on how you implemented the tooltip on the row.
Rows do not map to one and only one item, they are reused so you must update the tooltip when the row's data changes

@palexdev
Copy link
Owner

Anyway, as I said I see no more useful feedback/discussion here specifically related to MaterialFX, so I'm closing this issue

@ramprajapat94
Copy link

Hello @palexdev ,
Firstly, thank you so much for giving MaterialFX to JavaFX developers.

Secondly, I have gone through this solution: #176 (comment).
Just wanted to confirm that is there no way to customize/add columns (MFXTableColumn) to MFXTableView via scene builder?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not an issue Everything that is not an issue
Projects
None yet
Development

No branches or pull requests

5 participants