I am new to Vaadin, trying to figure out how I can implement column selection on headerClick in Vaadin (the expected result: i click on any column and it becomes selected, just like row).
Seems that it is not so obvious to do. Please, can anyone advice me on that issue? Thank you in advance!
Unfortunately, There is no API to do that in the current Grid and Table components. But as #Morfic mentioned you can configure a HeaderClickListener and then you'll have to save the column clicked as a state somewhere and add a wrapper on top of your datasource collection to get the data of the column in a scalar valued list.
If you need Excel-like features please check out Vaadin Spreadsheet component, it's a paid component but will work for you.
Related
Currently I'm working on a listgrid which is editable and my requirement is to create a a new row every time a user selects a row and presses the "Create" Button. The new row needs to be added immediately below the selected row. I tried using the below method
ListGrid.getRecordList().addAt(ListGridRecord rec, Index index)
However I got the warning message
15:48:04.373:MUP3:WARN:Log:ResultSets are readonly. This operation (addAt) will be ignored.
I've searched the smartgwt showcase to look for ways to edit a grid , so that new row is added at a specified index, however I wasn't able to find anything suitable.
I got to know that ResultSets is getting created because I'm using the statement
ListGrid.fetchData() Is there any way to solve this issue? Any suggestion is highly appreciated!
Muchas Gracias.
Figured it out, quite a weird trick...but works for me...
what you need to do is use grid.setRecords(grid.getRecords()); just before grid.getRecordList().addAt(rec, index); I think doing this makes the ResultSet editable.
Am working on a time sheet application with struts 1.2 and implementing jquery inside it. would appreciate greatly if i could get reply quickly ... am in learning curve in both jquery and struts ...
Requirement is this :
On the (+) button insert a row which populates dynamically and has two timepickers in it one used for determining timefrom, the other timeto, based on which duration is to be calculated. before clicking on (-) button user needs to check atleast one row for deleting that record. below are the screen shots.... the timepicker plugin i used is trentrichardson's. is this possible using jtable ? or jqgrid too ?? guys advise ...
i worked it around using some of the ideas from the other users. from a newbie on struts and java perspective i found that in struts tag library id and class are given as styleId and styleClass respectively.
eg:
is written as :-
Though am still interested in knowing whether the below can be corrected further ...
http://jsfiddle.net/manmohan_menon/6YkyY/4/
any advise will be greatly appreciated... thanks! :)
I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.
Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.
Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.
Current implementation: Here's the description of the different components and classes being used for the implementation:
ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
FileDisplayTableCellRenderer: Exists to always align cell content on the left
FileDisplayTableColumnModel: Does some mapping between internal types and column names
FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.
Possible solutions:
Preferably, I'd like to keep the current implementation and figure out how to correct the sorting, but I doubt someone can help me out with that!? Additionally their are some bits of code I had to add because of strange behaviours; they're commented in the code
The alternate option would be to change the JTable for another control altogether. I've made some research but didn't find the solution I was hoping for. The constraints are that
it must be embeddable in a swing UI
preferably it should support data bindings
support alternate row colours
row sorting
At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.
Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.
I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)
[edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.
It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."
Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.
I am doing a proyect which is a Database Manager, I have a list at the left side with all the table names I can choose, and in the right side I have the table. The problem is that I am doing something wrong and the JTable shows like this:
Anyone can say me what does that cell values mean?
thanks
You're probably trying to display hash map values in your table. When it goes to load them, it prints the class name and not the values. Same thing happens if you try to display a JLabel or something like that without using a custom table cell renderer.
Its hard to say for sure though. Please post code and we can help you better.
HI All,
I am desperately looking for the assistance on adding and removing the fields and rows using JSF. I am using ICE Faces for the rich UI look. The following is my problem:
I have to add one text box and two buttons (+) and (-) in a row.
When user clicks on the + button, one new row should be added with the above components.
When user clicks on the - button, the corresponding row should be removed from the display.
I am able to add the individual components like text box and remove it. But, here my challenging point is to add and remove as a row. How would I remove that specific row (instance) from the UI View Root.
I have tried several times, but till now I could not find a solution. Please suggest me the possible solutions.
Thanks in advance,
Krishna
Rather use a h:dataTable (or the IceFaces equivalent ice:dataTable) which is backed by a List<Data> contining objects which each represents the data of a single row. On Add just add a new Data item to the list. On Remove just remove the selected Data item from the list.
See also:
How to dynamically add new row to table? - detailed answer to similar question
Using Datatables - shows step by step how to use datatables in JSF 1.x.
CRUD datatable using #ViewScoped - simple example of JSF 2.0 CRUD