Announcement

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

    SelectItem

    v9.0p_2014-02-28/EVAL Deployment 2014-02-28
    Firefox/26.0

    Code:
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.types.GroupStartOpen;
    import com.smartgwt.client.types.SortDirection;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.grid.ListGrid;
    import com.smartgwt.client.widgets.grid.ListGridField;
    
    public class CompanySelectItem extends SelectItem {
    	
    	public CompanySelectItem() {
    		super();
    	}
    
    	public void setStatustypeID(Integer StatustypeID) {
    		Criteria myCriteria = new Criteria();
    		myCriteria.addCriteria("statustypeid", StatustypeID);
    		setOptionCriteria(myCriteria);
    	}
    	
    	public void setCompanytypeID(Integer CompanytypeID) {
    		Criteria myCriteria = new Criteria();
    		myCriteria.addCriteria("companytypeid", CompanytypeID);
    		setOptionCriteria(myCriteria);
    	}
    	
    	public void showCompanySelectItem() {
    		
    		setOptionDataSource(CompanyModule.companyDS);
    		setValueField("companyid");
    		setDisplayField("companyname");
    		setPickListWidth(300);
    		
    		ListGridField companynameField = new ListGridField("companyname", "Название");
    		ListGridField companytypeidField = new ListGridField("companytypeid", "Тип компании");
    		companytypeidField.setOptionDataSource(CompanytypeModule.companytypeDS);
    		companytypeidField.setDisplayField("companytypedescription");
    		companytypeidField.setAutoFetchDisplayMap(true);
    //		companytypeidField.setHidden(true);
    		
    		ListGrid pickListProperties = new ListGrid();  
    //		pickListProperties.setGroupStartOpen(GroupStartOpen.ALL);
    //		pickListProperties.setGroupByField("companytypeid");
    		pickListProperties.setSortDirection(SortDirection.DESCENDING);
    		pickListProperties.setSortField("companyname");
    		pickListProperties.setAutoFetchData(true);
            
    		setPickListProperties(pickListProperties);
    		setPickListFields(companynameField, companytypeidField);
    		
    		setAutoFetchData(true);
    	}
    }
    code example:

    Code:
            CompanySelectItem сompanyItem = new CompanySelectItem();
            сompanyItem.setStatustypeID(STATUSTYPE_ACTIVE);
            сompanyItem.showCompanySelectItem();
    Problem:

    companytypeidField.setDisplayField("companytypedescription")
    Do not give me the expected results (outputs "companytypeid" instead of "companytypedescription"). What am I doing wrong?

    #2
    a problem is found
    added to ds.xml OptionDataSource & DisplayField

    is there any possibility to add setHilites(hilites) in SelectItem?

    Comment


      #3
      Originally posted by code13 View Post
      is there any possibility to add setHilites(hilites) in SelectItem?
      I'm pretty sure you could do it with SelectItem.setPickListProperties(ListGrid pickListProperties).

      Best regards,
      Blama

      Comment


        #4
        Originally posted by Blama View Post
        I'm pretty sure you could do it with SelectItem.setPickListProperties(ListGrid pickListProperties).

        Best regards,
        Blama
        Unfortunately, no

        Comment


          #5
          Interesting.

          @Isomorphic: Isn't something like this supposed to work?

          Code:
          public class BuiltInDS implements EntryPoint {
          	public void onModuleLoad() {
          		KeyIdentifier debugKey = new KeyIdentifier();
          		debugKey.setCtrlKey(true);
          		debugKey.setKeyName("D");
          		Page.registerKey(debugKey, new PageKeyHandler() {
          			@Override
          			public void execute(String keyName) {
          				SC.showConsole();
          			}
          		});
          
          		DynamicForm boundForm = new DynamicForm();
          		SelectItem si = new SelectItem("status");
          		si.setOptionDataSource(DataSource.get("animals"));
          		ListGridField scientificNameLGF = new ListGridField("scientificName");
          		ListGridField statusLGF = new ListGridField("status");
          		ListGridField dietLGF = new ListGridField("diet") {
          			{
          				setCanSort(false);
          				setAlign(Alignment.RIGHT);
          			}
          		};
          		si.setPickListFields(scientificNameLGF, statusLGF, dietLGF);
          		si.setPickListWidth(400);
          
          		ListGrid listGridProperties = new ListGrid();
          		listGridProperties.setHilites(new Hilite[] { new Hilite() {
          			{
          				setFieldNames("status");
          				setCriteria(new Criterion("status", OperatorId.INOT_CONTAINS, "g"));
          				setCssText("color:#FF0000");
          			}
          		} });
          		si.setPickListProperties(listGridProperties);
          		boundForm.setFields(si);
          		boundForm.draw();
          	}
          }
          @code13: For easy cases try the technique used in the last box of this sample.

          Best regards,
          Blama

          Comment


            #6
            2 Blama:

            At present it is the only option.

            Try to use in your example setOptionDataSource and setGroupByField. It also will not work correctly

            for example:
            Code:
            ListGridField statusLGF = new ListGridField("status");
            statusLGF.setOptionDataSource(DataSource.get("statusTypes"));
            statusLGF.setAutoFetchDisplayMap(true);
            statusLGF.setDisplayField("statusdescr");
            ....
            
            listGridProperties.setGroupStartOpen(GroupStartOpen.ALL);
            listGridProperties.setGroupByField("status");
            the group name ("statusdescr") is displayed only after reopening SelectItem. At the same time everything works fine in ListGrid.
            there are many (in my opinion) limitations or bugs in the PickList that you can not see what you expect.

            sorry form my english and thanks for help o/
            Last edited by code13; 9 Apr 2014, 10:43.

            Comment


              #7
              2 Isomorphic:

              How to set data to SelectItem with with multiple fields ?

              Code:
              		ListGrid listgridProperties = new ListGrid();
              		SelectItem mySelectItem = new SelectItem();
              		
              		ListGridField roleidField = new ListGridField("roleid", "ID");
              		roleidField.setHidden(true);
              		ListGridField statustypeidField = new ListGridField("statustypeid", "Status");
              		statustypeidField.setHidden(true);
              		ListGridField roledescriptionField = new ListGridField("roledescription", "Role");
              		
              		mySelectItem.setPickListFields(roleidField, statustypeidField, roledescriptionField);
              		mySelectItem.setPickListWidth(200);
              		mySelectItem.setValueField("roleid");
              		mySelectItem.setDisplayField("roledescription");
              		
              		listgridProperties.setWrapCells(true);
              		listgridProperties.setFixedRecordHeights(false);
              		listgridProperties.setSortDirection(SortDirection.ASCENDING);
              		listgridProperties.setSortField("roleid");
              		listgridProperties.setShowHeaderMenuButton(false);
              		listgridProperties.setShowSortArrow(SortArrow.NONE);
              		listgridProperties.setShowAllRecords(true);
              		listgridProperties.setShowHeader(true);
              		
              		mySelectItem.setPickListProperties(listgridProperties);
              listgridProperties.setData(myRoleListGridRecord); - not working
              mySelectItem.setValueMap(Map valueMap); - not suitable

              ListGridRecord[] getClientPickListData() - there, but need setClientPickListData(ListGridRecord[])

              I need to set setEnabled(false) to record, but i can only recieve data using setAutoFetchData() or SetValueMap().

              tell me what I should do. thanks!

              Comment


                #8
                I too am looking to do something like that. I have a SelectItem that I want to show multiple fields on the drop down list. These fields are not referenced by a datasource so I cannot use the option datasource. All the data is loaded another way and I have it during creation of the SelectItem.

                Do I override the getClientPickListData method on the SelectItem and return the fields / data? Is that the intention of that method?

                Thanks!

                Comment


                  #9
                  This looks like an unrelated question to the above, but basically, regardless of where the data came from, you should make a clientOnly DataSource from it and use that as your optionDataSource.

                  Comment


                    #10
                    OK, that makes sense, sorry for the newbie question.

                    Thanks.

                    Comment

                    Working...
                    X