Announcement

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

    ListGrids and SelectItems

    Is there an easy way to populate the ListGridField that's being edited by the SelectItem with the selected record of the SelectItem instead of just the value field?

    #2
    We're not sure what that would mean (what gets displayed, stored, etc), but you can access the selected record via getSelectedRecord(), and if you've stored off the primaryKey value, you can also always fetch it via DataSource.fetchData().

    Comment


      #3
      Here's what I ended up implementing. I was hoping that there would be some way to drop the entire record from the select item into the list grid record.

      Code:
      ListGridField listGridField = new ListGridField("activity", "Activity"){{
      	setValueField("id");
      	setDisplayField("qualifiedName");
      	setRequired(true);
      	setOptionDataSource(dsActivities);
      	setDataPath("activity/id");
      	addChangedHandler(new com.smartgwt.client.widgets.grid.events.ChangedHandler() {
      		@Override
      		public void onChanged(com.smartgwt.client.widgets.grid.events.ChangedEvent event) {
      			Record record = grdActivities.getEditedRecord(event.getRowNum()).getAttributeAsRecord("activity");
      			ListGridRecord record0 = event.getItem().getSelectedRecord();
      			record.setAttribute("type", record0.getAttribute("type"));
      			record.setAttribute("pool", record0.getAttributeAsRecord("pool"));
      		}
      	});
      }};

      Comment


        #4
        There isn't anything built in to pull all fields from the selectItem into the listGrid record automatically. Your code basically looks fine, except we'd recommend you use ListGrid.setEditValue() or setEditValues() to populate the other fields in the record rather than doing record.setAttribute directly. That'll make sure the values get updated as "editValues" which then get saved through the normal flow, which'll handle a databound save, validation, etc.

        Regards
        Isomorphic Software

        Comment


          #5
          Thanks for the suggestions.

          Comment

          Working...
          X