Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Viritin MTable withGeneratedColumn places generated column last
This seems like a simple thing, but it isn't quite working for me. I'm creating a generated column with Viritin's MTable, but the column is always appearing last. The Column name appears in the correct place(first) but the data is incorrectly placed(last)
userTable.withGeneratedColumn("one", columnGenerator); userTable.withProperties("one", "two"); userTable.withColumnHeaders("One", "Two");
The data is loaded after the fact, like this:
userTable.lazyLoadFrom(pagingProvider, pagingProvider, defaultPageSize);
Any ideas on getting the column data to not appear last, would be greatly appreciated
Which version are you using? I tried following using the master branch and couldn't reproduce the issue:
Still not working for me. I tried changing my code to match yours and still no luck, age came last.
userSearchComponent.userTable.withGeneratedColumn("age", c -> "17 years") .withProperties("age", "name", "initials") .withColumnHeaders("Ikä/Age", "name", "initials") .lazyLoadFrom(firstRow -> getPresenter().search("as"), () -> 17);
There's two weird things about my setup. I'm using designer so the table is created before I do anything, so all this is being done after the fact. Also, normally this is a search page, so the table is populated even later than that. Though, in my example above I tried adding the data at the same time as the settings, though still after the designer had done its duty
Hmm, getting pretty hard to reproduce the issues. Did you use the latest version? Can you share some full (reduced) test code I could use to see what is going on?
I'm not sure if this will satisfy you, but I switched to MGrid and it worked properly. The code I posted in my last reply is code that shows the error for me. In the above example, The age column header appears first, but the actual age cells appear last. The only thing strange about my code in the above is that I'm using designer. So the table is added to the app through the designer and the above code is done after the instantiation. Please try with designer. If you still don't see it, I'll try to set up an example.
Another random related thing, there's a bug in MGrid where it requires the constructor that sets typesOfRows if you want to use generated columns, but if you're using designer you can only use the default constructor. I ended up setting a dummy container datasource of GeneratedPropertyListContainer to get around it.
I managed to reproduce it now and fixed the issue here:
For MGrid I created a method called setRowType that may be handy with designer.
I'll try to commit couple of half finished things and cut a release, so these should be in 1.52 pretty soon.
Awesome that you have used Viritin components with Designer. I haven't at all as I don't use Designer that much myself. It would be awesome if you could share some experiences to the Viritin wiki!