Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
jvx:client:gui:checkbox [2018/02/01 13:39]
admin
jvx:client:gui:checkbox [2020/06/26 11:53] (current)
cduncan
Line 1: Line 1:
 ~~NOTRANS~~ ~~NOTRANS~~
-~~Title: Work with ChoiceCellEditors instead of Checkboxes~~+~~Title: Work With Checkboxes~~
  
-JVx has checkboxes defined with ICheckbox, but such checkboxes are not automatically bound to the model. It's possible to bind checkboxes ​manually and update the state after value changed events. If you need a checkbox automatically bound to the model an IChoiceCellEditor is the class to use. +If you need native ​checkboxes ​that are automatically bound to your model, instead of fake [[jvx:​client:​gui:​checkbox|"​ChoiceCellEditor ​checkboxes"​]], ​you can use UICheckBoxCellEditor.
  
-The choice cell editor is not a real checkboxit is a cell editor ​that has a list of values and shows an image instead of the value. It's very easy to use it as checkbox, because the only things you need are two images. One image for checked state and one for unchecked state. You can e.g. use YES/NO, Y/N, TRUE/FALSE as checked/​unchecked values. The choice cell editor is very powerful because it offers multi-state checkboxes. This is what you need if you develop database applicationsbecause two states are not enough.+Howeverbe aware that such native checkboxes ​only have two states ​and two values (selected or unselected, ​e.g., Y or N). You can't set a custom value for null/emptybut this would be possible with UIChoiceCellEditor.
  
-== How to use the choice cell editor? ==+The advantage of native checkboxes is that they will fit your look and feel, but this would be also possible with custom images and choice cell editors.
  
-There are more options, but the easiest one is to set the cell editor for the column:+== Usage == 
 + 
 +The syntax ​is similar ​to [[jvx:​client:​gui:​checkbox|ChoiceCellEditors]],​ e.g.:
  
 <file java> <file java>
 rowDef.getColumnDefinition("​CHOOSE"​).getDataType(). rowDef.getColumnDefinition("​CHOOSE"​).getDataType().
-                                           ​setCellEditor(ApplicationUtil.YESNO_EDITOR);+                                           ​setCellEditor(ApplicationUtil.YESNO_CHECKBOX);
 </​file>​ </​file>​
  
-The ApplicationUtil defines default cell editors. The YESNO_EDITOR ​is defined as:+The ApplicationUtil defines default cell editors. The YESNO_CHECKBOX ​is defined as:
  
 <file java> <file java>
-new UIChoiceCellEditor(new Object [] {"​Y",​ "​N"​}, +new UICheckBoxCellEditor("​Y",​ "​N"​);​
-                       new String [] {UIImage.CHECK_YES_SMALL,​ UIImage.CHECK_SMALL},​ +
-                       ​UIImage.CHECK_SMALL);+
 </​file>​ </​file>​
  
-It's also possible to define default ​choice ​cell editors for an application:​+It's also possible to define default ​checkbox ​cell editors for an application:​
  
 <file java> <file java>
-UIChoiceCellEditor.addDefaultChoiceCellEditor(ApplicationUtil.YESNO_EDITOR); +UICheckBoxCellEditor.addDefaultCheckBoxCellEditor(ApplicationUtil.YESNO_CHECKBOX); 
-</java> +</file>
- +
-A default choice cell editor will be set automatically,​ for a column, if the metadata of the column defines allowed values. Allowed values could be set via check constraints in the database or via setAllowedValues in the column metadata. +
- +
-It works great if you use check constraints,​ enums or sets in your database, for specific columns, together with default choice cell editors. You don't need extra source code to show "​checkboxes"​. Everything will be auto-configured.+
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information