Hi,
I have a problem with the list grid filter... it does not work proper anymore. When I enter a filter criteria and press the "Filter" Icon... the listgrid gets filtered... but the entered criteria disappears in the filter criteria field. I can not reset the grid filter anymore.
Not working SmartGWT Version: https://www.smartclient.com/builds/S...GPL/2017-08-15
Browser: Chrome 60, Firefox (latest)
OS: Linux Mint
The above described issue does not appear in smartgwt Build from 2017-07-30
Thanks
Andy
You can try the following showcase to reproduce this error:
Entered Criteria Value before clicking the "Flther Icon"
After clicking the "Filter Icon"... the entered criteria disapears and the listGrid gets filtered (No reset possible):
I have a problem with the list grid filter... it does not work proper anymore. When I enter a filter criteria and press the "Filter" Icon... the listgrid gets filtered... but the entered criteria disappears in the filter criteria field. I can not reset the grid filter anymore.
Not working SmartGWT Version: https://www.smartclient.com/builds/S...GPL/2017-08-15
Browser: Chrome 60, Firefox (latest)
OS: Linux Mint
The above described issue does not appear in smartgwt Build from 2017-07-30
Thanks
Andy
You can try the following showcase to reproduce this error:
Code:
import java.util.Date; import java.util.LinkedHashMap; import com.google.gwt.user.datepicker.client.CalendarUtil; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.RecordList; import com.smartgwt.client.data.fields.DataSourceBooleanField; import com.smartgwt.client.data.fields.DataSourceDateField; import com.smartgwt.client.data.fields.DataSourceFloatField; import com.smartgwt.client.data.fields.DataSourceSequenceField; import com.smartgwt.client.data.fields.DataSourceTextField; import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.AutoFitWidthApproach; import com.smartgwt.client.types.FetchMode; import com.smartgwt.client.types.FieldType; import com.smartgwt.client.types.GroupStartOpen; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.RecordDropAppearance; import com.smartgwt.client.types.SummaryFunctionType; import com.smartgwt.client.util.PrintHTMLCallback; import com.smartgwt.client.util.PrintProperties; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLPane; import com.smartgwt.client.widgets.PrintCanvas; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.form.DynamicForm; 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.layout.VLayout; import com.smartgwt.client.widgets.toolbar.ToolStrip; import com.smartgwt.client.widgets.toolbar.ToolStripButton; import com.smartgwt.client.widgets.viewer.DetailViewer; public class GTestGrid { private ListGrid listGrid; private DynamicForm editorForm; public GTestGrid() { initPopUp(); } private void initPopUp() { initListGrid(); initEditorForm(); VLayout layout = new VLayout(); layout.setSize( "100%", "100%" ); layout.setMembers( editorForm, getToolBar(), listGrid ); layout.setOverflow( Overflow.HIDDEN ); Window window = new Window(); window.setOverflow( Overflow.HIDDEN ); window.setSize( "100%", "100%" ); window.setCanDragResize( true ); window.setShowMaximizeButton( true ); window.setShowMinimizeButton( true ); window.setShowCloseButton( false ); window.setAnimateMinimize( true ); window.setShowCloseButton( true ); window.setModalMaskOpacity( 50 ); window.setIsModal( true ); window.setShowModalMask( true ); window.centerInPage(); window.addItem( layout ); window.draw(); // listGrid.getResultSet().addDataChangedHandler( new DataChangedHandler() // { // // @Override // public void onDataChanged( DataChangedEvent event ) // { // double totalAmount = 0; // // // Gets all records of the listGrid // Record[] records = getAssignments(); // // for ( int i = 0; i < records.length; i++ ) // { // totalAmount = totalAmount + records[i].getAttributeAsDouble( CAssignedPaymentsRec.total_amount ); // } // } // } ); // add Records addRecords( 2 ); } private void initListGrid() { final DataSource dataSource = getDataSource(); listGrid = new ListGrid() { @Override protected Canvas getCellHoverComponent( Record record, Integer rowNum, Integer colNum ) { Criteria criteria = new Criteria(); criteria.addCriteria( dataSource.getPrimaryKeyFieldName(), record.getAttribute( dataSource.getPrimaryKeyFieldName() ) ); DetailViewer viewer = new DetailViewer(); viewer.setEmptyCellValue( "---" ); viewer.setDataSource( dataSource ); viewer.setWrapValues( false ); viewer.setWrapLabel( false ); viewer.setShowShadow( true ); viewer.setShowEmptyField( false ); viewer.setShowHiddenFields( true ); viewer.setShowEmptyField( false ); viewer.setShowDetailFields( true ); viewer.fetchData( criteria ); return viewer; } }; listGrid.setMargin( 25 ); listGrid.setDataSource( dataSource ); listGrid.setAutoFetchData( true ); listGrid.setDataFetchMode( FetchMode.BASIC ); listGrid.setAllowFilterExpressions( true ); listGrid.setShowFilterEditor( true ); listGrid.setAllowFilterExpressions( true ); listGrid.setShowRowNumbers( true ); listGrid.setFastCellUpdates( true ); listGrid.setEmptyCellValue( "---" ); listGrid.setWrapHeaderTitles( true ); listGrid.setCanResizeFields( true ); listGrid.setCellPadding( 4 ); listGrid.setFixedRecordHeights( false ); listGrid.setAutoFitWidthApproach( AutoFitWidthApproach.BOTH ); listGrid.setAutoFitHeaderHeights( true ); listGrid.setAutoSizeHeaderSpans( true ); listGrid.setCanAutoFitFields( false ); listGrid.setCanHover( true ); listGrid.setShowHover( true ); listGrid.setShowHoverComponents( true ); listGrid.setHoverDelay( 100 ); listGrid.setRecordDropAppearance( RecordDropAppearance.BOTH ); listGrid.setCanAddFormulaFields( true ); listGrid.setCanAddSummaryFields( true ); // Sets Columns setColumns( listGrid ); } private void setColumns( ListGrid listGrid ) { ListGridField idField = new ListGridField( "id" ); idField.setWidth( "10%" ); idField.setAlign( Alignment.CENTER ); idField.setShowGroupSummary( false ); idField.setHidden( true ); idField.setCanEdit( false ); ListGridField descriptionField = new ListGridField( "description" ); descriptionField.setWidth( "60%" ); descriptionField.setCanEdit( false ); ListGridField netField = new ListGridField( "netAmount" ); netField.setSummaryFunction( SummaryFunctionType.SUM ); netField.setShowGroupSummary( true ); netField.setShowGridSummary( true ); netField.setWidth( "10%" ); netField.setAlign( Alignment.CENTER ); netField.setFormat( "#,###,##0.00" ); ListGridField taxField = new ListGridField( "taxAmount" ); taxField.setWidth( "10%" ); taxField.setSummaryFunction( SummaryFunctionType.SUM ); taxField.setShowGroupSummary( true ); taxField.setShowGridSummary( true ); taxField.setAlign( Alignment.CENTER ); taxField.setFormat( "#,###,##0.00" ); ListGridField grossField = new ListGridField( "grossAmoumnt" ); grossField.setSummaryFunction( SummaryFunctionType.SUM ); grossField.setShowGroupSummary( true ); grossField.setShowGridSummary( true ); grossField.setAlign( Alignment.CENTER ); grossField.setWidth( "10%" ); grossField.setFormat( "#,###,##0.00" ); ListGridField currencyField = new ListGridField( "currency" ); currencyField.setAlign( Alignment.CENTER ); currencyField.setWidth( "8%" ); currencyField.setCanEdit( false ); ListGridField dateField = new ListGridField( "date" ); dateField.setWidth( "15%" ); dateField.setAlign( Alignment.LEFT ); ListGridField paidField = new ListGridField( "paid", "Paid" ); listGrid.setFields( idField, descriptionField, netField, taxField, grossField, paidField, dateField ); // Group ListGrid listGrid.setGroupByField( "currency" ); listGrid.setGroupStartOpen( GroupStartOpen.ALL ); listGrid.setShowGroupSummary( true ); listGrid.setShowGridSummary( true ); } private DataSource getDataSource() { DataSource ds = new DataSource(); ds.setID( "payments" ); ds.setClientOnly( true ); DataSourceSequenceField idField = new DataSourceSequenceField( "id", "ID" ); idField.setPrimaryKey( true ); idField.setHidden( true ); DataSourceTextField descriptionField = new DataSourceTextField( "description", "Description" ); descriptionField.setRequired( true ); DataSourceFloatField netField = new DataSourceFloatField( "netAmount", "Net Amount" ); netField.setRequired( true ); netField.setDecimalPrecision( 2 ); netField.setDecimalPad( 2 ); netField.setType( FieldType.LOCALEFLOAT ); DataSourceFloatField taxField = new DataSourceFloatField( "taxAmount", "Tax Amount" ); taxField.setRequired( true ); taxField.setDecimalPrecision( 2 ); taxField.setDecimalPad( 2 ); taxField.setType( FieldType.LOCALEFLOAT ); DataSourceFloatField grossField = new DataSourceFloatField( "grossAmoumnt", "Gross Amount" ); grossField.setRequired( true ); grossField.setDecimalPrecision( 2 ); grossField.setDecimalPad( 2 ); grossField.setType( FieldType.LOCALEFLOAT ); DataSourceTextField currencyField = new DataSourceTextField( "currency", "Currency" ); currencyField.setValueMap( getCurrencys() ); currencyField.setRequired( true ); DataSourceBooleanField paidField = new DataSourceBooleanField( "paid", "Paid" ); DataSourceDateField dateField = new DataSourceDateField( "date", "Date" ); ds.setFields( idField, descriptionField, netField, taxField, grossField, currencyField, paidField, dateField ); return ds; } private void initEditorForm() { editorForm = new DynamicForm(); editorForm.setDataSource( listGrid.getDataSource() ); editorForm.setAutoFocus( true ); editorForm.setWidth100(); editorForm.setMargin( 25 ); editorForm.setUseAllDataSourceFields( true ); editorForm.editNewRecord(); } private ToolStrip getToolBar() { ToolStrip toolbar = new ToolStrip(); toolbar.setWidth100(); ToolStripButton buttonAddToGrid = new ToolStripButton( "Add To Grid" ); buttonAddToGrid.addClickHandler( new ClickHandler() { public void onClick( ClickEvent event ) { if ( editorForm.validate() == true ) { editorForm.submit(); } } } ); ToolStripButton buttonNewRecord = new ToolStripButton( "New Record" ); buttonNewRecord.addClickHandler( new ClickHandler() { public void onClick( ClickEvent event ) { editorForm.editNewRecord(); } } ); ToolStripButton buttonPrint = new ToolStripButton( "<font color=\"red\">Print</font>" ); buttonPrint.addClickHandler( new ClickHandler() { @Override public void onClick( ClickEvent event ) { // Direct Print PrintProperties prop = new PrintProperties(); prop.setPrintForExport( true ); String html = listGrid.getPrintHTML( prop, new PrintHTMLCallback() { @Override public void setHTML( String html ) { System.out.println( html ); final HTMLPane htmlPane = new HTMLPane(); htmlPane.setContents( html ); PrintCanvas.printComponents( new Object[] { htmlPane } ); } } ); System.out.println( html ); } } ); toolbar.addButton( buttonNewRecord ); toolbar.addButton( buttonAddToGrid ); toolbar.addButton( buttonPrint ); return toolbar; } public Record[] getAssignments() { RecordList recordList = null; if ( listGrid.isGrouped() ) { recordList = listGrid.getOriginalRecordList(); } else { recordList = listGrid.getResultSet(); } Record[] result = (Record[]) recordList.toArray(); return result; } public LinkedHashMap<String, String> getCurrencys() { LinkedHashMap<String, String> items = new LinkedHashMap<String, String>(); items.put( "1", "EUR" ); items.put( "2", "GBP" ); items.put( "3", "CHF" ); items.put( "4", "SEK" ); items.put( "5", "DKK" ); items.put( "6", "PLN" ); items.put( "7", "BGN" ); items.put( "8", "CZK" ); items.put( "9", "HUF" ); items.put( "10", "HRK" ); items.put( "11", "RUB" ); items.put( "12", "RON" ); return items; } private void addRecords( int counter ) { Date date = getFirstDayOfMonth( new Date() ); Date date2 = getFirstDayOfMonth( new Date() ); for ( int i = 0; i < counter; i++ ) { ListGridRecord record = new ListGridRecord(); record.setAttribute( "id", 1 + i ); record.setAttribute( "description", "Test " + 1 + i ); record.setAttribute( "netAmount", new Double( 1000 + i ) ); record.setAttribute( "taxAmount", new Double( 0 ) ); record.setAttribute( "grossAmoumnt", new Double( 1000 + i ) ); record.setAttribute( "currency", "1" ); record.setAttribute( "paid", "true" ); CalendarUtil.addDaysToDate( date, 1 ); record.setAttribute( "date", date ); listGrid.addData( record ); } for ( int i = 0; i < counter; i++ ) { ListGridRecord record = new ListGridRecord(); record.setAttribute( "id", ( ( counter + 1 ) + i ) ); record.setAttribute( "description", "Test " + 1 + i ); record.setAttribute( "netAmount", new Double( 1 + i ) ); record.setAttribute( "taxAmount", new Double( 0 ) ); record.setAttribute( "grossAmoumnt", new Double( 1 + i ) ); record.setAttribute( "currency", "1" ); CalendarUtil.addDaysToDate( date2, 1 ); record.setAttribute( "date", date2 ); listGrid.addData( record ); } } // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ /** * Returns the first day of the current month */ // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public static Date getFirstDayOfMonth( Date date ) { CalendarUtil.resetTime( date ); CalendarUtil.setToFirstDayOfMonth( date ); return date; } }
Entered Criteria Value before clicking the "Flther Icon"
After clicking the "Filter Icon"... the entered criteria disapears and the listGrid gets filtered (No reset possible):
Comment