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.
Related
I have a Vaadin 14 Flow application that presents a grid of tasks that can be added to and deleted from as well as editing a selected task. Currently I have it set up so that if the user clicks a row (single select), it opens an editor so they can edit the task.
What I'd like to do is have a checkbox on each row that can be used as a multi-row selector to allow deleting multiple rows.
Would it be easier to just have the table be multiple selection enabled and just delete whatever row(s) are selected? I assume multi-selection allows the usual shift-click to select a contiguous range and control-click to select rows at random.
If I switch to multi-select, how will this affect the ability to simply click a row and have it open an editor for that row? If multiple rows are selected, what is likely to happen?
Update:
I'd never used multi-select until now. I didn't realize it provides checkboxes out of the box (no pun intended).
I had never used multi-select before and didn't realize that using that technique automatically adds a checkbox at the front of the row. Problem solved.
I am trying to recreate this "TreeGridWithCheckBoxFieldsExample" from the natTableExamples, and I wanted the first column editable, not only the Checkbox but also the Text it contains.
But when I register for TextCellEditor I am not able to set the CheckBox value by clicking it, if I click on CheckBox it goes to edit mode for the text beside it because of the MouseEditAction() in the below code.
uiBindingRegistry.registerFirstSingleClickBinding(
new CellPainterMouseEventMatcher(
GridRegion.BODY,
MouseEventMatcher.LEFT_BUTTON,
checkBoxPainter),
new MouseEditAction());
But if I remove it I won't be able to select the CheckBox, and because of DefaultBooleanDisplayConverter in the below code, the text after editing is not getting edited because the dataValue it gets is of boolean type .
configRegistry.registerConfigAttribute(
CellConfigAttributes.DISPLAY_CONVERTER,
new DefaultBooleanDisplayConverter(),
DisplayMode.NORMAL,
TreeLayer.TREE_COLUMN_CELL);
Thanks.
This is afaik not supported out of the box. Converters and editors are registered per column/cell. Mixing two editors and converters in one column/cell for two different properties of one row object is nothing to achieve easily. You will need to implement custom mechanisms to achieve that.
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 want to put subject results in a Jtable. I set DefaultTableModel to the table. In my table I have three columns.Student ID,Marks and Grade.Student ID is auto generated in column one.then user should enter marks for for second column.Then I want to automatically put the necessary grading in 3rd column.I load the grading data from the database and find the correct grading for the marks.I try this with both MouseReleaseEvent and KeyReleaseEvent.But it wasn't successful.Can any one suggest me a better way.thank you.
You don't have to listen for the input events, because the table has cell editors already. So you should be capable of editing your table. The only thing you need to do is to listen for the tableChanged event and update the database there.
See: TableModelListener
In case I was confused by your thoughts about the events and you just want to basically set values of a cell programmatically, try this method: setValueAt(Object,int,int)
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).