I've got a CellTable wich work with SingleSelectionModel to make single selection and show some information into details panel. Also I've got CheckBoxCell column into this CellTable which work with another MultipleSelectionModel to make mass delete operation.
When I try to click on check box in CheckBoxCell column GWT selects row and after second click on checkbox it change checkbox state. So we should make two clicks, but I need to do it (change checkbox state) by one click.
I tried different ways to fix it:
Change dependsOnSelection and handlesSelection parameters into CheckboxCell
Change SelectionEventManager in CellTable (DefaultSelectionEventManager.createCheckboxManager(), DefaultSelectionEventManager.createCustomManager)
But it doesn't work.
I found similar problems into Internet but all of them work with one MultipleSelectionModel. It's not the same what I want, because there's details panel (So I could make only single selection).
Can anyone help me to figure out how to resolve it?
UPD:
I've just removed SingleSelectionModel and redesigned UI to working with MultipleSelectionModel. It's GWT-hell..
Try to switch your selection models: use the MultiSelectionModel as the CellTable's selection model, so that the checkboxes work as expected (with both dependsOnSelection and handlesSelection set to true), and for the master-detail feature, use a CellPreviewEvent.Handler (or DefaultSelectionEventManager#createCustomManager), and RowStyles and getRowElement+addStyleName/removeStyleName for rendering (RowStyles when the CellTable renders the rows, then getRowElement to dynamically update styling).
Related
Welcome
In this table, I made the column mentioned cells editable to let the users make the needed value as they want ...
But they told me the values of this column can take just one of the values: 25,50,75,100, so, they asked me I make an options menu (like it is mention in the pic) allow them to choose directly the needed value and working fast.
So, how can I solve it, please!
(note: I'm working with java swing)
It's not the same question, but you can take a look on solution from below question:
How do I create a right click context menu in Java Swing?
you should create such listener, and add it to your Cell / Table.
you can take a look on below question to understand how to add listener to your Cell (it's not obvious :/)
JTable cell listener?
I have a NatTable component with the following layers:
ViewportLayer
SelectionLayer
RowHideShowLayer
ColumnGroupExpandCollapseLayer
ColumnHideShowLayer
DataLayer
I need to show/hide a specific column, when a checkbox selection changes. In order to that, I use the #doCommand() method provided by the NatTable component:
if(selection) {
nattable.doCommand(new ColumnShowCommand(nattable, COLUMN_INDEX));
} else {
nattable.doCommand(new ColumnHideCommand(nattable, COLUMN_INDEX+1));
}
Everything works just fine, excepting the case when ALL the items in the table are selected, and the ColumnHideCommand is executed. On this specific scenario, the whole table content disappears (Screenshot). If there is no selection in the table, or not all the elements are selected, then everything works just fine.
Please let me know if you have any idea what's going on there or if you experienced this kind of issues before. My experience with NatTables is quite limited, so please let me know if you need any additional information. Thank you!
This is a feature of the SelectionLayer to support multi column hide operations based on the column selection. A ColumnHideCommand get consumed and instead a MultiColumnHideCommand is created and executed based on the fully selected columns. The code in charge is located in SelectionLayer#handleColumnHideCommand(ColumnHideCommand). The method is protected, so if you don't need that feature because you only support column hide/show programmatically and not via UI performed by a user, you can override the method to simply perform a super.doCommand(command); without the check for selections.
I have a very basic problem with jtable. I have a jtable that has multiple columns with one of column having a button. When i click on that button a panel drops, and asks to select an option from given options. When i select that option, value replaces in one of the column.
Now, i want when i select multiple rows, and do the same thing as above, it should replace that column in all the selected rows.
Problem: Currently, my table is losing selection when i am clicking the button in one of the column in jtable after multiple row selection.
I searched google and stackoverflow a lot, but could not find anything meaningful. Anyhelp or sample code is appreciated.
Thanks
If I understood your problem correctly then the solution is fairly simple.
First of all the issue probably occurs because once you click on the button java sets a new focus on the button and therefore clearing the focus on the other rows. That won´t be a problem in a single selection because you still click into the selected row, however doing that with multiple rows in one go won´t work that way.
To solve this you need to save your previous selections in something like an ArrayList and after the whole option thing you can apply the changes to every element in the ArrayList and reload the table.
A cleaner and more intuitive approach though would be to place the button outside of the JTable.
I have a JTable in my code.
And whenever there is an update to any specific column in the row (cell basically), I will update the corresponding icon in that cell.
so I'm basically following these steps.
Step 1: I update the model.
Step2 2: I'm calling
tableModel.fireTableCellUpdated(tableRowIndex, tableColumnIndex);
This works fine.
But problem comes when I drag and drop the columns from one position to another in Table header. And whenever there is an update to any specific cell, I follow the same steps as I mentioned before.
Problem: I'm not seeing the Icon painted. But if I bring the focus on top of that row in table it is painting the icon.
Observation: I see the tableRowIndex and tableColumnIndex are correct after dragging the columns.
Just for testing I added this piece of code in the problem scenario.
examTable.repaint(examTable.getCellRect(examTableRowIndex, examTableColumnIndex, true));
This is repainting the cell properly.
But this is not the right solution I guess. I tried to debug the code I didn't find much about the problem
I'm calling tableModel.fireTableCellUpdated(tableRowIndex, tableColumnIndex);
That is wrong. You should never invoke the firXXX methods directly. That is the job of the TableModel to invoke the appropriate event when the data is changed.
I will update the corresponding icon in that cell.
All you need to do is invoke model.setValueAt(...) method to change the Icon and the model will notify the table that data has changed so the table can repaint itself.
examTable.repaint(...)
Again you should not need to manually invoke repaint on the table
But problem comes when I drag and drop the columns from one position to another in Table header.
Not sure why you need special code for this if you follow the advice from above. But if for some reason it is still necessary then you need to look at the convertColumnIndex...(...) methods to make sure you are using the proper index for your column.
I have a ListGrid that has 4 columns. When I edit the grid (using a DoubleClick event on a record) I'd like the user to only be able to edit one column.
However, I'd like the user to be able to click an 'Add' button, which will call startEditingNew(), where I'd like them to have all columns available for edit.
Can this be done?
Thanks!
I guess both of the requirements can not be applied at the same time but both of them can be implemented in two different grid..
or else you can also try by making all of the columns editable at first and then by by handling DoubleClickHandler you can restrict some columns editing by their column index.But it is totally experiment.
I would try to add in the doubleclick handler some code using setCanEdit (false) to the listGridField You don't want to touch.
In the button click handler you can set to true for all the fields.