SmartClient Version: v10.1p_2016-01-07/PowerEdition Deployment (built 2016-01-07)
Not browser specific; tried with FireFox 24, IE 11, and Chrome Version 47.0.2526.106 m (64-bit)
Description:
When using toolbar buttons on a com.smartgwt.client.widgets.Dialog, the buttons cannot be enabled/disabled programatically after they are drawn.
For example, during creation, a button can be disabled, but cannot be re-enabled from a selection handler on a list grid.
Sample Code:
In the sample, the "Delete" button is displayed to the user as a disabled button, as expected. However, when selecting an item in the ListGrid, the button is not enabled.
When stepping through the code, I can see that the SelectionChangedHandler is invoked as expected, and the setDisabled(false) call made.
NOTE: The enabling/disabling of this button worked with SmartGWT 5 and SmartGWT 4.1.
For example, it works as expected with SmartClient Version: v10.0p_2015-08-28/PowerEdition Deployment (built 2015-08-28)
Not browser specific; tried with FireFox 24, IE 11, and Chrome Version 47.0.2526.106 m (64-bit)
Description:
When using toolbar buttons on a com.smartgwt.client.widgets.Dialog, the buttons cannot be enabled/disabled programatically after they are drawn.
For example, during creation, a button can be disabled, but cannot be re-enabled from a selection handler on a list grid.
Sample Code:
Code:
package com.smartgwt.sample.showcase.client.dataintegration.java.file; import java.util.ArrayList; import java.util.List; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Dialog; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler; import com.smartgwt.client.widgets.grid.events.SelectionEvent; import com.smartgwt.client.widgets.events.ClickHandler; public class MySampleDlg extends Dialog { private static final int HEIGHT = 320; private static final int WIDTH = 566; private static final int LISTGRID_HEIGHT = 220; private final ListGrid myListGrid = new ListGrid(); final Button deleteButton = new Button( "Delete" ); public MySampleDlg() { this.initialize(); } private void initialize() { this.setWidth( WIDTH ); this.setHeight( HEIGHT ); final Button okButton = new Button( "OK" ); this.setTitle( "My Sample Dialog" ); this.setToolbarButtons( okButton, this.deleteButton ); this.setCanDragReposition( Boolean.TRUE ); this.setShowMinimizeButton( Boolean.FALSE ); this.setIsModal( Boolean.TRUE ); this.setShowModalMask( Boolean.TRUE ); this.centerInPage(); okButton.addClickHandler( new ClickHandler() { @Override public void onClick( com.smartgwt.client.widgets.events.ClickEvent event ) { MySampleDlg.this.close(); } } ); // disabled until an item is selected. this.deleteButton.setDisabled( true ); this.initializeListGrid(); this.addItem( this.myListGrid ); } private void initializeListGrid() { final List<ListGridField> fields = new ArrayList<ListGridField>(); fields.add(new ListGridField ("Jan", "January")); fields.add(new ListGridField ("Feb", "February")); fields.add(new ListGridField ("Mar", "March")); fields.add(new ListGridField ("Apr", "April")); fields.add(new ListGridField ("May", "May")); fields.add(new ListGridField ("Jun", "June")); fields.add(new ListGridField ("Jul", "July")); fields.add(new ListGridField ("Aug", "August")); fields.add(new ListGridField ("Sep", "September")); fields.add(new ListGridField ("Oct", "October")); fields.add(new ListGridField ("Nov", "November")); fields.add(new ListGridField ("Dec", "December")); char maxProduct = 'E'; List<ListGridRecord> salesData = new ArrayList<ListGridRecord>(); for (char prod = 'A'; prod <= maxProduct; prod++) { ListGridRecord rec = new ListGridRecord(); rec.setAttribute("product", "Product " + prod); long minSales = Math.round(Math.random() * 8000) + 2000; long maxVariance = minSales / 3; for (ListGridField field : fields) { rec.setAttribute(field.getName(), Math.round(Math.random() * maxVariance) + minSales); } salesData.add(rec); } final ListGridField field = new ListGridField("product", "Products"); field.setCanEdit(Boolean.FALSE); fields.add(0, field); this.myListGrid.setHeight( MySampleDlg.LISTGRID_HEIGHT ); this.myListGrid.setFields(fields.toArray(new ListGridField[0])); this.myListGrid.setData(salesData.toArray(new ListGridRecord[0])); this.myListGrid.addSelectionChangedHandler( new MyListGridSelectionChangedHandler() ); } private final class MyListGridSelectionChangedHandler implements SelectionChangedHandler { @Override public void onSelectionChanged( SelectionEvent event ) { ListGridRecord[] records = MySampleDlg.this.myListGrid.getSelectedRecords(); if ( records == null || records.length == 0 ) { MySampleDlg.this.deleteButton.setDisabled( true ); } else { MySampleDlg.this.deleteButton.setDisabled( false ); } } } }
When stepping through the code, I can see that the SelectionChangedHandler is invoked as expected, and the setDisabled(false) call made.
NOTE: The enabling/disabling of this button worked with SmartGWT 5 and SmartGWT 4.1.
For example, it works as expected with SmartClient Version: v10.0p_2015-08-28/PowerEdition Deployment (built 2015-08-28)
Comment