Java Code Examples for com.smartgwt.client.widgets.grid.ListGrid#setEditEvent()
The following examples show how to use
com.smartgwt.client.widgets.grid.ListGrid#setEditEvent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComparatorsPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private void prepareAssociationsGrid() { associationsGrid = new ListGrid(); associationsGrid.setEmptyMessage(I18N.message("notitemstoshow")); associationsGrid.setShowFilterEditor(true); associationsGrid.setFilterOnKeypress(true); associationsGrid.setAutoFetchData(true); associationsGrid.setEditByCell(true); associationsGrid.setSelectionType(SelectionStyle.SINGLE); associationsGrid.setEditEvent(ListGridEditEvent.CLICK); associationsGrid.setDataSource(new ComparatorsDS(null)); associationsGrid.setAllowFilterOperators(true); associationsGrid.setShowRecordComponents(true); associationsGrid.setShowRecordComponentsByCell(true); ListGridField in = new ListGridField("in", I18N.message("ext"), 40); ListGridField comparator = new ListGridField("comparator", I18N.message("comparator")); comparator.setWidth("*"); comparator.setCanEdit(!Session.get().isDemo()); comparator.setCellFormatter(new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { String label = getComparatorShortName(value != null ? value.toString() : null); boolean enabled = record.getAttributeAsBoolean("eenabled"); if (!enabled) label = "<span style='color:red;'>" + label + "</span>"; return label; } }); comparator.setFilterEditorProperties(ItemFactory.newFormatConverterSelector()); associationsGrid.setFields(in, comparator); associationsGrid.setEditorCustomizer(new ListGridEditorCustomizer() { public FormItem getEditor(ListGridEditorContext context) { ListGridField field = context.getEditField(); if (field.getName().equals("comparator")) { final ListGridRecord selectedRecord = associationsGrid.getSelectedRecord(); final SelectItem editorItem = ItemFactory .newComparatorSelector(selectedRecord.getAttributeAsString("in")); editorItem.setWidth("*"); return editorItem; } else return context.getDefaultProperties(); } }); associationsGrid.addEditCompleteHandler(new EditCompleteHandler() { @Override public void onEditComplete(EditCompleteEvent event) { Record converterRecord = settingsGrid.find(new AdvancedCriteria("id", OperatorId.EQUALS, associationsGrid.getSelectedRecord().getAttributeAsString("comparator"))); if (converterRecord != null) associationsGrid.getSelectedRecord().setAttribute("eenabled", converterRecord.getAttributeAsBoolean("eenabled")); } }); }
Example 2
Source File: FormatConvertersPanel.java From document-management-software with GNU Lesser General Public License v3.0 | 4 votes |
private void prepareAssociationsGrid() { associationsGrid = new ListGrid(); associationsGrid.setEmptyMessage(I18N.message("notitemstoshow")); associationsGrid.setShowFilterEditor(true); associationsGrid.setFilterOnKeypress(true); associationsGrid.setAutoFetchData(true); associationsGrid.setEditByCell(true); associationsGrid.setSelectionType(SelectionStyle.SINGLE); associationsGrid.setEditEvent(ListGridEditEvent.CLICK); associationsGrid.setDataSource(new FormatConvertersDS(null, null)); associationsGrid.setAllowFilterOperators(true); associationsGrid.setShowRecordComponents(true); associationsGrid.setShowRecordComponentsByCell(true); ListGridField in = new ListGridField("in", I18N.message("in"), 40); ListGridField out = new ListGridField("out", I18N.message("out"), 40); ListGridField converter = new ListGridField("converter", I18N.message("converter")); converter.setWidth("*"); converter.setCanEdit(!Session.get().isDemo()); converter.setCellFormatter(new CellFormatter() { @Override public String format(Object value, ListGridRecord record, int rowNum, int colNum) { String label = getConverterShortName(value != null ? value.toString() : null); boolean enabled = record.getAttributeAsBoolean("eenabled"); if (!enabled) label = "<span style='color:red;'>" + label + "</span>"; return label; } }); converter.setFilterEditorProperties(ItemFactory.newFormatConverterSelector()); associationsGrid.setFields(in, out, converter); associationsGrid.setEditorCustomizer(new ListGridEditorCustomizer() { public FormItem getEditor(ListGridEditorContext context) { ListGridField field = context.getEditField(); if (field.getName().equals("converter")) { final ListGridRecord selectedRecord = associationsGrid.getSelectedRecord(); final SelectItem editorItem = ItemFactory.newFormatConverterSelector( selectedRecord.getAttributeAsString("in"), selectedRecord.getAttributeAsString("out")); editorItem.setWidth("*"); return editorItem; } else return context.getDefaultProperties(); } }); associationsGrid.addEditCompleteHandler(new EditCompleteHandler() { @Override public void onEditComplete(EditCompleteEvent event) { Record converterRecord = settingsGrid.find(new AdvancedCriteria("id", OperatorId.EQUALS, associationsGrid.getSelectedRecord().getAttributeAsString("converter"))); if (converterRecord != null) associationsGrid.getSelectedRecord().setAttribute("eenabled", converterRecord.getAttributeAsBoolean("eenabled")); } }); }