Announcement

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

    Nested ListGrid Date Format problems

    I am running RHEL with SmartGWTEE 3.0 NB 20120516. I am using the Nested ListGrid. I have a date column and a Document Type column among other columns as part of the listgrid among other fields. The date column I want formatted to shortdate and I have the following code
    Code:
     ListGridField dateField = theListGrid.getField(DATE_CREATED);
          setColumnDateSelectorFormat(dateField, DateDisplayFormat.TOUSSHORTDATETIME);
    The method called is implemented as follows:
    Code:
    public void setColumnDateSelecetorFormat(ListGridField dateField, DateDisplayFormat format)
    {
    	MiniDateRangeItem datePicker = new MiniDateRangeItem();
    	datePicker.setDateDisplayFormat(format);
    	dateField.setFilterEditortype(datePicker);
    }
    Then for the document type field I have a multiple select datasource for it. When I create the listgrid as a normal listgrid, then the select item shows up and the date shows up in proper format. When I add the line
    Code:
     theAvailableReportsListGrid.setCanExpandRecords(true);
    The formatting disappears and so does the select item. The date shows up including microseconds, which I don't want and the select item for the document type completely disappears.
    Last edited by azuniga; 21 May 2012, 06:52.

    #2
    We need a way to reproduce the problem to help (there's no general problem with setCanExpandRecords as you can see from samples).

    However, one thing that jumps out is that you seem to be trying to make changes to fields after data binding has occurred, and the right way to do this is to provide field definitions to the ListGrid via setFields() that already have the properties you want - see the Data Binding chapter of the QuickStart for an overview and code samples.

    Comment


      #3
      I moved the field definitions to be ahead of setFields. Here is the code for the outer listgrid:
      Code:
       String[] fieldNames = DataSource.get(DATA_SOURCE_NAME).getFieldNames();
            if (fieldNames != null)
            {
               ListGridField[] fieldArray = new ListGridField[fieldNames.length];
               int counter = 0;
               for (String name : fieldNames)
               {            
                  fieldArray[counter] = new ListGridField(name);
                  if(name.equals(DOCUMENT_TYPE_NAME))
                  {
                     fieldArray[counter].setOptionDataSource(DataSource.get(DOCUMENT_TYPES_DATASOURCE));
                     fieldArray[counter].setAutoFetchDisplayMap(true);
                     
                     // Create the select item that will be used by the list grid field.
                     SelectItem selectItem = new SelectItem();
      
                     // allow multiple parameters to be selected for the same field
                     selectItem.setMultiple(true);
                     selectItem.setAllowEmptyValue(true);
                     fieldArray[counter].setFilterEditorProperties(selectItem);
                  }
                  else if(name.equals(DATE_CREATED))
                  {
                     // set the date format for the date created time field
                     setColumnDateSelectorFormat(fieldArray[counter], DateDisplayFormat.TOUSSHORTDATETIME);
                  }
                  counter++;
               }
               theAvailableDOCUMENTsListGrid.setFields(fieldArray);
      The inner list grid code is just as the example. I'm doing the same thing as the example. The outer listgrid has field definitions but is also the same as the example.

      Comment


        #4
        OK - we're still going to need a way to reproduce the problem to help further. Can you make the same thing happen by just modifying the sample code?

        Comment


          #5
          The problem has been resolved by re-ordering the code. Thank you.

          Comment

          Working...
          X