Announcement

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

    5.1p SelectItem and sorting: sortField needed as pickListField?

    Hi Isomorphic,

    I noticed a strange behavior and I'm not sure if it has always been this way or is a bug.
    I have a SelectItem with optionDataSource and a sortField. The displayField is not set via displayField, but via setPickListFields().
    Now, if I don't include the sortField in the list of setPickListFields(), the request to the server does not include sortBy and the list is not sorted on the client either (=not displayed sorted in the GUI).

    I know that if I want to use setCriterionGetter() I need to have the fields I want to generate criteria from in the setPickListFields()-list, usually as hidden fields.

    But is this also true for sorting? If not, I can provide a testcase using latest 5.1p.

    Best regards
    Blama

    #2
    We probably do need a test case here as it's unclear which fields are in common.

    Note that even if you set up multiple fields that are displayed to the user via setPickListFields(), you still need to configure a displayField.

    Comment


      #3
      Hi Isomorphic,

      please see this v10.1p_2016-07-08 based testcase which does not include a sortBy in the request if the respective field is missing in the SelectItem's picklist:

      BuiltInDS.java:
      Code:
      package com.smartgwt.sample.client;
      
      import com.google.gwt.core.client.EntryPoint;
      import com.smartgwt.client.Version;
      import com.smartgwt.client.core.KeyIdentifier;
      import com.smartgwt.client.data.DataSource;
      import com.smartgwt.client.util.Page;
      import com.smartgwt.client.util.PageKeyHandler;
      import com.smartgwt.client.util.SC;
      import com.smartgwt.client.widgets.IButton;
      import com.smartgwt.client.widgets.Window;
      import com.smartgwt.client.widgets.events.ClickEvent;
      import com.smartgwt.client.widgets.events.ClickHandler;
      import com.smartgwt.client.widgets.form.DynamicForm;
      import com.smartgwt.client.widgets.form.fields.SelectItem;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.client.widgets.layout.VLayout;
      
      public class BuiltInDS implements EntryPoint {
          private VLayout mainLayout;
          private IButton recreateBtn;
      
          public void onModuleLoad() {
              KeyIdentifier debugKey = new KeyIdentifier();
              debugKey.setCtrlKey(true);
              debugKey.setKeyName("D");
      
              Page.registerKey(debugKey, new PageKeyHandler() {
                  public void execute(String keyName) {
                      SC.showConsole();
                  }
              });
      
              mainLayout = new VLayout(20);
              mainLayout.setWidth100();
              mainLayout.setHeight100();
      
              recreateBtn = new IButton("Recreate");
              recreateBtn.addClickHandler(new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                      recreate();
                  }
              });
              mainLayout.addMember(recreateBtn);
              recreate();
              mainLayout.draw();
          }
      
          private void recreate() {
              Window w = new Window();
              w.setWidth("95%");
              w.setHeight("95%");
              w.setMembersMargin(0);
              w.setModalMaskOpacity(70);
              w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
              w.setTitle("TITLE" + w.getTitle());
              w.setShowMinimizeButton(false);
              w.setIsModal(true);
              w.setShowModalMask(true);
              w.centerInPage();
      
              DynamicForm df = new DynamicForm();
              SelectItem si = new MySelectItem("EmployeeId");
              df.setFields(si);
      
              w.addItem(df);
              w.show();
          }
      
          private class ListGridFieldHidden extends ListGridField {
              public ListGridFieldHidden(String name) {
                  super(name);
                  setHidden(true);
              }
          }
      
          private class MySelectItem extends SelectItem {
              public MySelectItem(String name) {
                  super(name);
                  setTitle("Sorttest");
                  setOptionDataSource(DataSource.get("employees"));
                  setValueField("EmployeeId");
                  setDisplayField("Name");
                  [B]setSortField("Gender");[/B]
      
                  setRequired(true);
                  setValidateOnChange(true);
      
                  ListGridField empname = new ListGridField("Name");
                  ListGridFieldHidden EmployeeId = new ListGridFieldHidden("EmployeeId");
                  ListGridFieldHidden EmployeeType = new ListGridFieldHidden("EmployeeType");
                  ListGridFieldHidden Gender = new ListGridFieldHidden("Gender");
      
                  [B]// setPickListFields(EmployeeId, empname, EmployeeType, Gender);
                  setPickListFields(EmployeeId, empname, EmployeeType);[/B]
              }
          }
      }
      Also note the strange pagesize of 78 for the request (tested with FF26 Dev Mode). Was this changed on purpose?

      Note that even if you set up multiple fields that are displayed to the user via setPickListFields(), you still need to configure a displayField.
      This is correct of course. I had a valueMap here in my case and misinterpreted this fact.

      Best regards
      Blama
      Last edited by Blama; 14 Jul 2016, 02:43. Reason: Added version information: v10.1p_2016-07-08

      Comment


        #4
        You're right - the pickList shouldn't need a definition for the Gender field, as long as the field is available in the DS.

        We've made a couple of changes to address that, back to 5.1 - you can test the fix by changing your code to use setSortField("Gender", "Name"), to see the list sorted first by the missing Gender field, and then the visiible name field

        Please also re-check that server sortBy is being sent as expected, and let us know if your row-count issue remains.

        Comment


          #5
          Hi Isomorphic,

          there is no change in behavior at all (also not for sorting) using v10.1p_2016-07-18 (FF26 Dev Mode).
          Did the change make it into this version?

          Best regards
          Blama

          Comment


            #6
            No, the change was only made today - it will hit builds tomorrow.

            Comment


              #7
              Hi Isomorphic

              the issue regarding the sort is fixed now (sortBy is also in the request properties in the Developer Console).
              The row count issue remains, though.

              Two requests are sent, the 2nd after the 1st was processed on the client.
              1st:
              Code:
              {
                  dataSource:"employees", 
                  operationType:"fetch", 
                  componentId:"isc_PickListMenu_2", 
                  data:{
                  }, 
              [B]    startRow:0, 
                  endRow:78, [/B]
                  sortBy:[
                      "Gender", 
                      "Name"
                  ], 
                  textMatchStyle:"startsWith", 
                  resultSet:[ResultSet ID:isc_ResultSet_2 (dataSource: employees, created by: isc_PickListMenu_2)], 
                  callback:{
                      caller:[ResultSet ID:isc_ResultSet_2 (dataSource: employees, created by: isc_PickListMenu_2)], 
                      methodName:"fetchRemoteDataReply"
                  }, 
                  willHandleError:true, 
                  showPrompt:false, 
                  prompt:"Finding Records that match your criteria...", 
                  oldValues:{
                  }, 
                  requestId:"employees$6274", 
                  internalClientContext:{
                      requestIndex:1
                  }, 
                  fallbackToEval:false, 
                  componentContext:"isc_DynamicForm_2.EmployeeId", 
                  lastClientEventThreadCode:"MUP2", 
                  bypassCache:true, 
                  dataProtocol:"getParams"
              }
              2nd:
              Code:
              {
                  dataSource:"employees", 
                  operationType:"fetch", 
                  componentId:"isc_PickListMenu_2", 
                  data:{
                  }, 
              [B]    startRow:78, 
                  endRow:153, [/B]
                  sortBy:[
                      "Gender", 
                      "Name"
                  ], 
                  textMatchStyle:"startsWith", 
                  resultSet:[ResultSet ID:isc_ResultSet_2 (dataSource: employees, created by: isc_PickListMenu_2)], 
                  callback:{
                      caller:[ResultSet ID:isc_ResultSet_2 (dataSource: employees, created by: isc_PickListMenu_2)], 
                      methodName:"fetchRemoteDataReply"
                  }, 
                  willHandleError:true, 
                  showPrompt:false, 
                  prompt:"Finding Records that match your criteria...", 
                  oldValues:{
                  }, 
                  requestId:"employees$6275", 
                  internalClientContext:{
                      requestIndex:2
                  }, 
                  fallbackToEval:false, 
                  componentContext:"isc_DynamicForm_2.EmployeeId", 
                  lastClientEventThreadCode:"TMR3", 
                  bypassCache:true, 
                  dataProtocol:"getParams"
              }
              Most likely it is better to handle this in this bug report, as the main sorting issue is solved now.

              Best regards
              Blama

              Comment

              Working...
              X