Announcement

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

    setEditorType / getSelectedRecord is not a function

    Hi folks,

    Code:
            DataSourceField field = new DataSourceIntegerField ("valueInside", "Value Column");
            field.setRequired (true);
            
            final SelectItem item = new SelectItem("itemID");  
            item.setTitle("Item");  
            item.setOptionDataSource(SupplyCategoryXmlDS.getInstance());  
            item.setValueField("categoryName");  
            item.setDisplayField("categoryName");
            item.addChangedHandler(new ChangedHandler() {
    			@Override
    			public void onChanged(ChangedEvent event) {
    				Object result = item.getSelectedRecord(); // Error here!!! - self.getSelectedRecord is not a function
    			}
    		});
            field.setEditorType(item);
            
            addField (field);
    Error: self.getSelectedRecord is not a function

    Question: Why is not possible to call the method getSelectedRecord() from item (SelectItem) object ?!!!!

    Thansk!

    #2
    Are you still having issue with this? Usually that comes from the fact your inside a handler so it is looking for the function in the Handler's class, but your code looks correct. Try calling another function from item and see if you can produce the same error.

    Comment


      #3
      I tried it already but...

      Hi svjard,

      thanks for your fast replay. Yes Iīm still having this issue :-(.
      I tried with some methods from the item element but it doesnīt seem to work.
      getValues, getValueFields, etc. But I get always the same error.
      I believe that it searches the method in the Handler class but it doesnīt make any sense to me. I call the method using the item object (item.getSelectedRecord()) so how come that this stup** framework mingle objects.

      Do you have any ideas?

      Thanks in advance :-)

      Comment


        #4
        Well likely with your code somewhere else, do you have any other things named "item"? Try using this though inside your handler:
        Code:
        SelectItem i =  (SelectItem)event.getItem();
        i.getSelectedRecord();

        Comment


          #5
          Same error

          Hi,

          didnīt work. Just the same error message :-(

          Thanks

          Comment


            #6
            May be it's smartclient bug, try:

            Code:
             ListGrid grid = new ListGrid();
             ListGridField nameField = new ListGridField("name");
             ComboBoxItem editor = new ComboBoxItem();
             nameField.setEditorType(editor);
             DynamicForm f = new DynamicForm();
             f.setVisible(false);
             f.setFields(editor);
             grid.setFields(nameField);
             grid.addChild(f);
            and so ... getValue, fetchData ... etc works :)

            Comment


              #7
              I have the same issue. Could it be related to the use of SelectItem in setEditorType() ? I have also observed misbehaviour of SpinnerItem when used as a setEditorType() of a different item (Here is the Link : http://forums.smartclient.com/showthread.php?t=11115)

              also you dont get an error without setEditorType as below;

              Code:
                      final SelectItem item = new SelectItem("itemID");  
                      item.setTitle("Item");  
                      item.setOptionDataSource(SupplyCategoryXmlDS.getInstance());  
                      item.setValueField("categoryName");  
                      item.setDisplayField("categoryName");
                      item.addChangedHandler(new ChangedHandler() {
              			@Override
              			public void onChanged(ChangedEvent event) {
              				Object result = item.getSelectedRecord(); // Error here!!! - self.getSelectedRecord is not a function
              			}
              		});
                      DynamicForm df = new DynamicForm();
                      df.setFields(item);
                      df.show();

              Comment


                #8
                You must create a new object using the javaScript Object!
                Here is the solution!

                Code:
                SelectItem curItem = new SelectItem(aEvent.getItem().getJsObj());
                if (curItem.getSelectedRecord() != null){
                	if(currentListGrid != null){
                		if(vm == null){
                			int editRow = currentListGrid.getEditRow();
                			currentListGrid.setEditValue(editRow, getCreditorBicField(), curItem.getSelectedRecord().getAttribute("bic"));
                		}else{
                			vm.setValue(getCreditorIbanField(), curItem.getSelectedRecord().getAttribute("iban"));
                		}
                	}
                }

                Comment

                Working...
                X