Announcement

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

    ListGrid:setEditorCustomizer DateItem format issue

    PROBLEM

    setEditorCustomizer sort of works for a cell that has it's date explicitly set. I can make changes to that set cell and the format is in TOUSSHORTDATE. So my dates look like:
    Code:
    4/28/2015
    However (here's the sort of works), when I change the date in another column (same row) whose value has not been set yet, then the date format changes to for example:
    Code:
    Tue Apr 28 12:00:00 2015
    Then I go back to the original column with the explicitly set date and make a change, then I get:

    Code:
    Tue Apr 1 12:00:00 2015
    So it seems that the date formatter changes from TOUSSHORTDATE to a different format. Note that in the code that I set the DateItem date formatter explicitly to TOUSSHORTDATE.

    Please advise as to how I can keep the date formatter from changing.




    1.SNAPSHOT_v10.1d_2015-04-27/Enterprise Deployment 2015-04-27

    Code:
        public void onModuleLoad() {
            	
            RootPanel.get("body_block").add(testing());
        }
        public ListGrid testing()
     {
    		final ListGrid grid = new ListGrid();
    		grid.setWidth(750);
    		grid.setHeight(500);
    		grid.setEditorCustomizer(new ListGridEditorCustomizer() {
    			public FormItem getEditor(ListGridEditorContext context) {
    				// ListGridField field = context.getEditField();
    				ListGridRecord record = (ListGridRecord) context
    						.getEditedRecord();
    
    				int row = grid.getRowNum(record);
    				SC.logWarn("Got row: " + row);
    				switch (row) {
    				case 0:
    					SpinnerItem spinnerItem = new SpinnerItem();
    					return spinnerItem;
    				case 1:
    					DateItem di = new DateItem();
    					// di.setUseTextField(true);
    					di.setDateFormatter(DateDisplayFormat.TOUSSHORTDATE);
    					//di.setFormat("MM/DD/YYYY");
    					return di;
    				default:
    					return context.getDefaultProperties();
    				}
    			}
    		});
    
    		grid.setCanEdit(true);
    		grid.setEditEvent(ListGridEditEvent.CLICK);
    		grid.setEditByCell(true);
    		
    		ListGridField[] dsf = new ListGridField[3];
    		
    		int i = 0;
    		dsf[i] = new ListGridField("C1");
    		dsf[i].setWidth(100);
    		dsf[i].setType(ListGridFieldType.TEXT);
    		dsf[i].setTitle(null);
    		dsf[i].setShowTitle(false);
    		i++;
    		
    		dsf[i] = new ListGridField("C2");
    		dsf[i].setWidth(100);
    		dsf[i].setType(ListGridFieldType.TEXT);
    		i++;
    
    		dsf[i] = new ListGridField("C3");
    		dsf[i].setWidth(100);
    		dsf[i].setType(ListGridFieldType.TEXT);
    		i++;
    
    		grid.setFields(dsf);
    
    		Record[] rr = new Record[4];
    		Record r;
    		
    		r = new Record();
    		r.setAttribute("C1", "Version");
    		rr[0] = r;
    		r = new Record();
    		r.setAttribute("C1", "Effective");
    		r.setAttribute("C2", "1/2/2016");
    		rr[1] = r;
    		r = new Record();
    		r.setAttribute("C1", "ARB11");
    		r.setAttribute("C2", "2");
    		rr[2] = r;
    		r = new Record();
    		r.setAttribute("C1", "ARB12");
    		r.setAttribute("C3", "2");
    		rr[3] = r;
    		grid.setData(rr);
    
    		return grid;
    	}

    #2
    This has been resolved by using Date objects when setting the value of the records.

    When using strings, the formats become confused, which seems odd. Perhaps the system wide date format becomes corrupt or altered?

    Comment


      #3
      Glad to hear you figured this out.

      The value of a date/datetime/time field is always a Date object. Using a String as the value is just incorrect usage, and can lead to lots of problems.

      Comment

      Working...
      X