Announcement

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

    Form Field Width not changing

    So I am using SmartGWT 4.0 inside the latest version of Chrome.
    I am trying to build a simple set of 4 side by side TextBoxes to act as an IP address input area (one field for each octet). So each Textbox is actually a HLayout containing a DynamicForm and a DataSourceIntegerField. The issue I am running into is that I have tried about 100 different ways to get the textboxes to a width of about 30 pixels but cannot get there. No matter what I do, I get 4 evenly spacing fields at about 100+ pixels. This value never changes despite my best effort and hours of hair pulling. Here is the constructor code for a single entry (they are call this same class.)

    Code:
    	public IPOctetTextBox() 
    	{ 
    		super();
    		
    		
    		DataSource dataSource = new DataSource();
    	
    		IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
    		integerRangeValidator.setMin(0);
    		integerRangeValidator.setMax(255);
    		
    		dsIntegerField = new DataSourceIntegerField ("intField", "", 3);
    		dsIntegerField.setValidators(integerRangeValidator);
    		dsIntegerField.setLength(3);
    		dsIntegerField.setTitle("");
    		
    		
    		dataSource.setFields (dsIntegerField);
    		
    		form = new DynamicForm();
    		form.setNumCols(1);
    		form.setTitleSuffix("");
    		form.setColWidths(20);
    		form.setTitleWidth(1);
    		form.setWidth100();
    		form.setOverflow(Overflow.VISIBLE);
    
    		
    		form.setDataSource (dataSource);
    		
    		FormItem[] fields = form.getFields();
    		for (int i = 0; i < fields.length; i++) {
    			FormItem formItem = fields[i];
    			formItem.setWidth(null);
    		}
    		
    		setWidth (50);
    		addMember (form);
    		
    		draw();
    	}
    Am I missing something basic? BTW, IPOctetTextBox extends HLayout.

    #2
    Take a look at the Form Layout overview. You're doing a bunch of odd things here, like:

    - trying to minimize the title column when you can just eliminate it (showTitle:false)

    - having two columns but providing only one colWidth (the system warns you about this too)

    - setting width to null on the item. You can either set the width here, or, to fill the column, setWidth("*"), but don't set null.

    Comment


      #3
      Confused

      I apologize for my ignorance here. Just trying to understand your comments:

      "trying to minimize the title column when you can just eliminate it (showTitle:false)" - I dont see any functions for disabling the title on the form entry.

      "having two columns but providing only one colWidth (the system warns you about this too)" - How are there two columns when I am doing form.setNumCols(1)?

      "setting width to null on the item. You can either set the width here, or, to fill the column, setWidth("*"), but don't set null." - this was just one suggestion I read somewhere. Doesn't seem to affect anything whether it is there or not.

      Comment


        #4
        Another Related Question

        As a side question, is there a minimum width for form entry fields?

        Comment


          #5
          Once again, start by reading the Form Layout overview. It covers all these questions, that's why just about all of the properties you have been using feature a prominent link to it in JavaDoc.

          Comment


            #6
            Again...

            Trust me, I have read through Form Layout Overview again and again. No matter which direction I take, the underlying textbox will not go below some value. There is no setWidth function for it so I cannot even manipulate its size. The entire reason I am even going the form route is for the input validation. Here is where I stand:

            Code:
            	public IPOctetTextBox() 
            	{ 
            		super();
            		
            		
            		DataSource dataSource = new DataSource();
            	
            		IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
            		integerRangeValidator.setMin(0);
            		integerRangeValidator.setMax(255);
            		
            		dsIntegerField = new DataSourceIntegerField ("intField", "", 3);
            		dsIntegerField.setValidators(integerRangeValidator);
            		dsIntegerField.setLength(3);
            		dsIntegerField.setTitle("");
            		
            		
            		dataSource.setFields (dsIntegerField);
            		
            		form = new DynamicForm();
            		form.setNumCols(2);
            		form.setTitleSuffix("");
            		form.setColWidths(1,20);
            		form.setFixedColWidths(true);
            		form.setWidth(25);
            
            		
            		form.setDataSource (dataSource);
            		
            		setWidth(70);
            		addMember (form);
            		
            		draw();
            	}
            Setting the width of the overlying HLayout has 0 effect. I have tried setting the HLayout's overflow to hidden. The form will get clipped but is still clearly larger than the layout even though I have set the form's Width to 25. So again I ask, is there a minimum width for TextBox's (or more importantly DataSourceIntegerField ) contained within forms that I do not see? Do you have any other suggestions? I have literally been at this for hours scouring the net for any help to no avail.

            Comment


              #7
              How curious, you're moving in the exact opposite direction of our advice!

              You're still not using the showTitle:false property we mentioned in the first post.

              Now you're not even trying to set a width on the FormItem. Again, you need to set a pixel width on the item, or set it to "*" to fill the column, but do not set it to null, and do not omit a setting for it, because the default on a TextItem is 150.

              Comment


                #8
                Last Post

                Ok, this will be my last attempt as it appears you are not reading or understanding my code (which is almost verbatim from one of the smartgwt examples.). First off, I am using a DataSourceIntegerField, NOT a TextItem. That gets set in a data source which then gets added to the form. (Please refer to your own Integer Validation example under forms in the SmartGWT gallery).

                Calling FormItem[] fields = form.getFields() returns an empty array which is why I removed the FOR loop where I was setting the width to NULL. Setting the width value there is pointless as there appears to be 0 form items. The DataSourceIntegerField has 0 methods for setting any kind of size nor does the DataSource. Setting the size on the DynamicForm yields nothing. So WHERE exactly am I suppose to call setWidth()??

                Comment


                  #9
                  Looks like you haven't read the Data Binding chapter of the QuickStart Guide, which will show you how you can use FormItems in conjunction with DataSourceFields so that you can call setWidth().

                  Comment


                    #10
                    Be sure not to miss the related sample (the QuickStart Guide already points you here, of course).

                    Comment

                    Working...
                    X