Announcement

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

    #16
    The other thread says:

    "However when I use this field in a ListGrid I only ever see the id number of the value field and not the text of the display field. If I select to open the drop down list I see the options in text as you would expect, but if I select one I immediately see id number once again."

    This is exactly the problem I am having.

    Comment


      #17
      Take a closer read, he appears to be saying he sees the id value in the comboBox, and he specifically states that he never sees the displayField value at all, looks unrelated or at any rate, too vague to tell.

      Comment


        #18
        I read it that he sees the text fields in the drop down list, and the numeric value in the field after the selection has been made, which is the same as me.

        Comment


          #19
          Here's another example, with real datasources. Let me just state again what I am having trouble with:

          The List Grid field has a select item editor backed by an option data source.
          The option data source returns id / name pairs. When I use the drop down the select item looks ok - I can select from a list of names.
          After the option is selected and the focus moves off the field. The numeric id is displayed in the grid - not the expected name field.
          When the save button is pressed the records are persisted to the server, I can see in the RPC tab that the name field of the record contains the numeric id. This probably explains why it does not display correctly in the list grid before saving.

          This problem ONLY occurs with an option data source. If I use a static value map to populate the editor everything works fine.

          I have attached a screenshot showing the list grid with the numeric ids displayed.

          Here is the code for the app:

          Code:
          public class SandboxSelect implements EntryPoint {
          
          	private static final String NAME = "name";
          	private static final String ID = "id";
          	
          	public void onModuleLoad() {
          
          		final ListGrid grid = new ListGrid();
          		grid.setCanEdit(true);
          		grid.setAutoSaveEdits(false);
          		grid.setAutoFitData(Autofit.BOTH);
          
          		grid.setDataSource(GridDataSource.getInstance());
          
          		ListGridField idField = new ListGridField();
          		idField.setTitle("Item");
          		idField.setWidth(100);
          		idField.setName(ID);
          		
          		// Set value and display field so that the 
          		// human readable value is shown 
          		idField.setValueField(ID);
          		idField.setDisplayField(NAME);
          
          		// Use an Option data source 
          		SelectItem editor = new SelectItem();
          		editor.setOptionDataSource(OptionDataSource.getInstance());
          		editor.setValueField(ID);
          		editor.setDisplayField(NAME);
          				
          		idField.setEditorType(editor);
          
          		grid.setFields(idField);
          		
          		Button editButton = new Button("Edit New");
          		editButton.addClickHandler(new ClickHandler() {
          			
          			public void onClick(ClickEvent event) {
          				grid.startEditingNew();
          			}
          		});
          		
          		Button saveButton = new Button("Save");
          		saveButton.addClickHandler(new ClickHandler() {
          			
          			public void onClick(ClickEvent event) {
          				grid.saveAllEdits();
          			}
          		});
          				
          		VLayout vLayout = new VLayout();
          		vLayout.setMembersMargin(10);
          		vLayout.addMember(grid);
          		vLayout.addMember(editButton);
          		vLayout.addMember(saveButton);
          
          		vLayout.draw();
          	}
          }
          Here is the code for the grid data source:

          Code:
          public class GridDataSource extends RestDataSource{
          
          	public static final String ID = "id";
          	public static final String NAME = "name";
          	
          	private static GridDataSource instance = null;
          
          	public static synchronized GridDataSource getInstance() {
                  if (instance == null) {
                      instance = new GridDataSource("gridDs");
                  }
                  return instance;
              }
          
              protected GridDataSource(String dsid) {
              	
                  setID(dsid);
                  setRecordXPath("//record");
                  setTagName("record");
                  
                  DataSourceField id = new DataSourceField(ID, FieldType.TEXT, "Id");
                  DataSourceField name = new DataSourceField(NAME, FieldType.TEXT, "Name");
                  
                  setFields(id, name);
          		
                  setFetchDataURL("Sandbox/rest/grid/fetch");
          		OperationBinding fetch = new OperationBinding();
          		fetch.setOperationType(DSOperationType.FETCH);
          		fetch.setDataProtocol(DSProtocol.POSTXML);
          		
                  setUpdateDataURL("Sandbox/rest/grid/update");
          		OperationBinding update = new OperationBinding();
          		update.setOperationType(DSOperationType.UPDATE);
          		update.setDataProtocol(DSProtocol.POSTXML);
          		
                  setAddDataURL("Sandbox/rest/grid/add");
          		OperationBinding add = new OperationBinding();
          		add.setOperationType(DSOperationType.ADD);
          		add.setDataProtocol(DSProtocol.POSTXML);
          		
                  setRemoveDataURL("Sandbox/rest/grid/remove");
          		OperationBinding remove = new OperationBinding();
          		remove.setOperationType(DSOperationType.REMOVE);
          		remove.setDataProtocol(DSProtocol.POSTXML);
          		
          		setOperationBindings(fetch, add, update, remove);
              }
          }
          Here is the code for the option data source

          Code:
          public class OptionDataSource extends RestDataSource{
          
          	public static final String ID = "id";
          	public static final String NAME = "name";
          	
          	private static OptionDataSource instance = null;
          
          	
              public static synchronized OptionDataSource getInstance() {
                  if (instance == null) {
                      instance = new OptionDataSource("optionDs");
                  }
                  return instance;
              }
          
              protected OptionDataSource(String dsid) {
              	
                  setID(id);
                  setRecordXPath("//option");
          
                  DataSourceTextField valueField = new DataSourceTextField(ID);
                  DataSourceTextField displayField = new DataSourceTextField(NAME);
                  
                  setFields(displayField, valueField);
          		
                  setFetchDataURL("Sandbox/rest/options/fetch");
          		OperationBinding fetch = new OperationBinding();
          		fetch.setOperationType(DSOperationType.FETCH);
          		fetch.setDataProtocol(DSProtocol.POSTXML);
          		setOperationBindings(fetch);
              }
          }
          Here is the entry from the RPC tab for a saved record. Note the "name" field contains an id.

          Code:
          {
              "dataSource":"gridDs", 
              "operationType":"add", 
              "componentId":"isc_ListGrid_0", 
              "data":"\r<request>\r    <data>\r        <record>\r            <id>3</id>\r            <name>3</name>\r        </record>\r    </data>\r    <dataSource>gridDs</dataSource>\r    <operationType>add</operationType>\r    <componentId>isc_ListGrid_0</componentId>\r    <oldValues></oldValues>\r</request>", 
              "callback":"isc_ListGrid_0.$337(dsResponse, dsRequest)", 
              "willHandleError":true, 
              "showPrompt":false, 
              "clientContext":{
                  "saveCallback":"this.$335(rowNum,0,colNum,editCompletionEvent,success)", 
                  "newValues":{
                      "id":"3", 
                      "name":"3"
                  }, 
                  "editInfo":{
                      "editValuesID":"_1", 
                      "rowNum":1, 
                      "colNum":null, 
                      "values":'$$BACKREF$$:.dataSource.operationType.componentId.data.callback.willHandleError.showPrompt.clientContext.saveCallback.newValues', 
                      "oldValues":null, 
                      "editCompletionEvent":"programmatic"
                  }
              }, 
              "requestId":"gridDs$6272"
          }
          Attached Files

          Comment


            #20
            As another example, which might be easier for you to use, I have modified the Showcase GridDependentSelelects sample.

            I have attempted to have the Item field in the remote example use the SKU, but display the item name. After selecting a value and adding a new record the SKU is displayed, not the item name.

            Screenshot showing results attached.

            What would be the correct way to make this change?

            Edits from line 118 of GridDependentSelectSample.java
            Code:
                 // ListGridField itemField = new ListGridField("itemName", "Item");   // REMOVED
                    
                    ListGridField itemField = new ListGridField("SKU", "Item");  // ADDED
                    itemField.setValueField("SKU");  // ADDED
                    itemField.setDisplayField("itemName"); // ADDED
                    SelectItem itemEditor = new SelectItem();
                    itemEditor.setPickListFilterCriteriaFunction(new FilterCriteriaFunction() {
                        public Criteria getCriteria() {
                            String category = (String) remoteDataGrid.getEditedCell(remoteDataGrid.getEditRow(), "categoryName");
                            return new Criteria("category", category);
                        }
                    });
            
            
                    itemEditor.setOptionDataSource(supplyItemDS);
                    itemEditor.setValueField("SKU");   // ADDED 
                    itemEditor.setDisplayField("itemName");  //ADDED
                    itemField.setEditorType(itemEditor);
            Logging the contends of the grid after an item is added shows a record with the SKU in the itemName field:

            Code:
            [ERROR] [Sandbox] - 14:00:25.519:MUP0:WARN:Log:{SKU: "58119904",
            quantity: 1,
            categoryName: "Office Paper Products",
            itemName: "58119904"}
            Attached Files
            Last edited by stevesloss; 7 Sep 2011, 05:12.

            Comment


              #21
              Thanks for putting the time into help pin this down.
              We've now made a change in both the 2.5 and 3.x branches to resolve this issue. If you continue to have problems with it on nightly builds going forward, please let us know

              Comment


                #22
                You're welcome. I have tried the nightly and it works great.
                Thanks a lot for turning round a fix so quickly.

                Comment


                  #23
                  Is this fixed in 2.5P

                  Comment


                    #24
                    Problem with SelectItem

                    Originally posted by Isomorphic View Post
                    Thanks for putting the time into help pin this down.
                    We've now made a change in both the 2.5 and 3.x branches to resolve this issue. If you continue to have problems with it on nightly builds going forward, please let us know
                    I am using Version 3.1p and I am having an exactly the same problem described in the previous posts.

                    Here is the code sample:

                    ListGridField onHandQtyLGF = new ListGridField(ON_HAND_ATTRIBUTE, ON_HAND_LABEL);
                    onHandQtyLGF.setType(ListGridFieldType.INTEGER);
                    onHandQtyLGF.setAlign(Alignment.CENTER);
                    onHandQtyLGF.setCanEdit(false);

                    // ATTENTION!!!!!!!! Problem in GWT framework: http://forums.smartclient.com/showthread.php?t=18646
                    final SelectItem freezersSI = new SelectItem();

                    freezersSI.setDisplayField(FREEZER_ATTRIBUTE);
                    freezersSI.setValueField(ID_ATTRIBUTE);
                    freezersSI.setOptionDataSource(DataSource.get("Freezers"));
                    freezersSI.setShowTitle(false);


                    freezersSI.addChangedHandler(new ChangedHandler() {
                    public void onChanged(ChangedEvent changedEvent) {
                    GWT.log("Freezer: " + changedEvent.getItem().getDisplayValue());
                    GWT.log("Freezer ID: " + changedEvent.getValue().toString());
                    }
                    });

                    Comment


                      #25
                      Be sure to specify your *exact* version (with date stamp) when posting.

                      This issue has been fixed for a while, so whatever is going on for you must be something different. Try starting a new thread and explaining the problem from scratch, with enough detail to allow us to comment.

                      Comment

                      Working...
                      X