SmartGWT 2.2 gpl
NetBeans 6.9.1
GWT 2.0.4
Mozilla Firefox
Dear community,
I need to allow the user to pick an element from a datasource-linked list giving the possibility of entering a new item (combobox style).
When the user makes his choice I need to get the entire record selected, well I didn't succeed in it through the method getSelectedRecord associated to the event.getItem() inside ChangeHandler.
Code:
Well, even if I choose a file from the list, the record got from event.getItem().getSelectedRecord() is always null.
I made several trials:
- If I use SelectItem instead of ComboBoxItem, it works: I can successfully read the record associated to the selection.
- If I override the method getSelectedRecord of my combobox as suggested in several posts
I can appreciate no changes.
- No changes even if I set the datasource directly to the ComboBoxItem.
I'm currently using SelectItem as a temporary patch but I would really appreciate any suggestion of work-around.
Yary Ribero
NetBeans 6.9.1
GWT 2.0.4
Mozilla Firefox
Dear community,
I need to allow the user to pick an element from a datasource-linked list giving the possibility of entering a new item (combobox style).
When the user makes his choice I need to get the entire record selected, well I didn't succeed in it through the method getSelectedRecord associated to the event.getItem() inside ChangeHandler.
Code:
Code:
private final ListGridField fileName = new ListGridField( "fileName", "Select from the List" ); ... //final SelectItem itemEditor = new SelectItem(); final ComboBox itemEditor = new ComboBox(); itemEditor.setFilterLocally( true ); itemEditor.setAddUnknownValues( true ); itemEditor.setPickListFilterCriteriaFunction( new FilterCriteriaFunction() { public Criteria getCriteria() { if ( project == null ){ IWDebug.error( "project is null "); return ProjectRecord.getFilterAllMODs(); } return project.getMODCriteria(); } } ); //itemEditor.setOptionDataSource( IWStructure.getUser().getMODList() ); fileName.setOptionDataSource( IWStructure.getUser().getMODList() );
Code:
fileName.addChangedHandler( new ChangedHandler() { public void onChanged( final ChangedEvent event ) { if ( event == null ) return; if ( event.getItem() == null ){ return; IWDebug.notice( "event.getItem class: " + event.getItem().getClass().getName() ); final Record record = event.getItem().getSelectedRecord(); if ( record == null ){ IWDebug.message( "No known output file selected." ); /*It means that user want to specify the name of a new file*/ return; } final String fileID = record.getAttribute( "modID" ); IWDebug.message( "fileID: " + fileID ); IWDebug.message( "file Name: " + record.getAttribute( "fileName" ) ); final ModelRecord model = new ModelRecord( record ); model.setFileID( fileID ); } } );
I made several trials:
- If I use SelectItem instead of ComboBoxItem, it works: I can successfully read the record associated to the selection.
- If I override the method getSelectedRecord of my combobox as suggested in several posts
Code:
@Override public native ListGridRecord getSelectedRecord() /*-{ var self = this.@com.smartgwt.client.core.DataClass::getJsObj()(); var ret = self.getSelectedRecord(); if(ret == null || ret === undefined) return null; var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); if(retVal == null) { retVal = com.smartgwt.client.widgets.grid.ListGridRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret); } return retVal; }-*/;
- No changes even if I set the datasource directly to the ComboBoxItem.
I'm currently using SelectItem as a temporary patch but I would really appreciate any suggestion of work-around.
Yary Ribero
Comment