Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ComboboxItem as a ListGridField EditorType

    Hi,

    I am trying to use a comboboxitem as the editortype for a ListGridField. Below is the code that sets up the comboboxitem editortype for the ListGridField:

    Code:
                    clients = new ComboBoxItem("clientCombo");		
    		DataSourceField pk = clientsDS.getField("ID");
    		pk.setPrimaryKey(true);
    		clients.setOptionDataSource(clientsDS);
    		clients.setPickListCriteria(new Criteria("ROLE", "INVESTOR"));
    		clients.setValueField("FP_ID");
    		clients.setDisplayField("FULL_NAME");
    		clients.setFilterFields("FULL_NAME");
    		clients.setCompleteOnTab(true);
    
                    pickListProperties.setAutoFetchData(false);
                     pickListProperties.setShowHeader(false);
    
    		clients.setPickListProperties(pickListProperties);
    		ListGridField fullName = new ListGridField("FULL_NAME");
    		clients.setPickListWidth(280);
    
    		clients.addChangedHandler(new ChangedHandler() {
    
    			public void onChanged(ChangedEvent event) {
    				FormItem item = event.getItem();
    				DynamicForm form = event.getForm();
    
    				SC.logWarn("valuefield value: " + item.getValue());
    				
    			}
    		});
    
    		setEditByCell(true);
    		setEditEvent(ListGridEditEvent.CLICK);
    		setAutoSaveEdits(false);
    		setConfirmCancelEditing(true);
    		ListGridField clientName = getField("USER.FULL_NAME");
    		clientName.setCanEdit(true);
    		clientName.setEditorType(clients);
    		clientName.setFilterEditorType(new TextItem());
    I have 2 questions regarding using this usage scenario.

    1) When the ComboboxItem.ChangedHandler gets fired, how do I get a reference to the actula ComboboxItem instance that fired he event, so I that can get the SelectedRecord if any off of it. I tried doing event.getItem(), but that only returned a FormItem, not a ComboboxItem. the event.getForm(), and event.getSource() did not help either.

    2) It seems that whenever I set the DisplayField as follows:
    Code:
               clients.setDisplayField("FULL_NAME");
    it screws up the criteria setting on the OptionDataSource. More specifically, every time I go into edit mode in the ListGridField, I see requests in the developer console where the criteria is set the FP_ID = "FULL_NAME" value. I don't know why setting the DisplayField value has anything to do with the Criteria setting, which I thought should always be set according to this line of code:
    Code:
    		clients.setPickListCriteria(new Criteria("ROLE", "INVESTOR"));
    I am using SmartGWT 2.5 latest nightly build, and IE8 on Windows 7.

    Thanks in advance,
    Mike

    #2
    Hi,

    Any idea as to what I am doing wrong here, or as to what could be happening here, or a workaround. I am kind of stuck here.

    Thanks,
    Mike

    Comment


      #3
      1) this is due to GWT's lack of support for reflection. You can use

      new ComboBoxItem(event.getItem().getJsObj())

      .. as a kind of "typecast" to switch to the right type

      2) see FormItem.fetchMissingValues

      Comment


        #4
        Thanks very much Iso, that worked.

        Comment

        Working...
        X