Announcement

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

    problem with getselectedrecord() in selectitem

    Hi,
    I am getting below error when I try to access getselectedrecord() in selectItem..


    Code:
    SelectItem item = new SelectItem();
    DataSource locationDS = LocationGwtRpcDataSource.getInstance();

    ListGridField type = new ListGridField("locationType");
    type.setWidth(50);
    ListGridField location = new ListGridField("name");

    item.setWidth(200);
    item.setOptionDataSource(locationDS);
    item.setValueField("id");
    item.setDisplayField("name");
    item.setPickListWidth(350);
    item.setPickListFields(type, location);


    final ListGridField location = new ListGridField("locationName");
    location.setEditorType(item);
    location.setWidth(item.getWidth());
    location.setCanEdit(true);



    location.addEditorExitHandler(new EditorExitHandler(){

    @Override
    public void onEditorExit(EditorExitEvent event) {

    if (event.getNewValue() != null) {
    Object i = item.getSelectedRecord().getAttribute("id");
    }
    }
    });

    it is giving below error...Please let me know how to solve this.




    com.google.gwt.core.client.JavaScriptException: (TypeError): Object doesn't support this property or method
    number: -2146827850
    description: Object doesn't support this property or method
    at com.smartgwt.client.widgets.form.fields.SelectItem.getSelectedRecord(Native Method)
    at com.sikorsky.fmoc.client.composer.grid.AircraftHoursGrid$1.onEditorExit(AircraftHoursGrid.java:91)
    at com.smartgwt.client.widgets.grid.events.EditorExitEvent.dispatch(EditorExitEvent.java:96)
    at com.smartgwt.client.widgets.grid.events.EditorExitEvent.dispatch(EditorExitEvent.java:1)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:65)
    at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:53)
    at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:178)
    at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:189)


    Thanks,
    Steve.

    #2
    setEditorType is only used to configure the "properties" of the editor, and you cannot use it later in code as a "live" FormItem instance by calling methods on it.

    Comment


      #3
      Hi,
      Thanks very much for your reply..I tried following thing also..still getting the same issue..

      item.addChangedHandler(new ChangedHandler() {
      public void onChanged(ChangedEvent event) {
      SelectItem obj = (SelectItem)event.getSource();
      Integer codi = obj.getSelectedRecord().getAttributeAsInt("id");

      }
      });

      Please help me in solving this..

      Thanks

      Comment


        #4
        Post in detail what you're trying to accomplish. The dependent selects sample in showcase might help you.

        Comment


          #5
          Hi,
          I am having an issue when selecting data in selectitem. I attached selectitem to the listgrid field. For the select item i added value field and display field seperately. Initially when loading the data in selectitem shows correctly(shows the name), but when I edited the record, changed the value in selectitem..then the listgridfield shows the "id"(setValueField("id")) but not "name"( setDisplayField("name");)

          Please let me know how can I solve it.

          Comment

          Working...
          X