Announcement

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

    ListGrid filter row

    I have a problem with ListGrid filter row date format. I'm setting proper format for field but filter editor has it's own format. Do i need to set it manually? How to do it? I want to use custom format so none of DateDisplayFormat patterns suit my needs.

    The second question is how to tell ListGrid to show date range dialog instead of simple picker?
    Im using smartgwt-lgpl 6.0-p20161016

    Code:
     
       public static final int RECORD_COUNT = 5;
    
      public void onModuleLoad()
      {
        ListGrid grid = new ListGrid();
        grid.setShowFilterEditor(true);
        grid.setFilterLocalData(true);
        grid.setWidth(600);
        grid.setHeight(400);
    
        ListGridField lgf1 = new ListGridField("F1", "Field 1", 100);
        lgf1.setType(ListGridFieldType.DATE);
        lgf1.setFormat("yyyy-MM-dd");
        lgf1.setCanFilter(true);
    
        ListGridField lgf2 = new ListGridField("F2", "Field 2", 100);
        lgf2.setType(ListGridFieldType.DATE);
        lgf2.setFormat("yyyy.MM.dd");
        lgf2.setCanFilter(true);
    
        ListGridField lgf3 = new ListGridField("F3", "Field 3", 100);
        lgf3.setType(ListGridFieldType.DATE);
        lgf3.setFormat("yyyy - MM - dd");
        lgf3.setCanFilter(true);
    
        grid.setFields(lgf1, lgf2, lgf3);
        grid.setData(getData());
        RootPanel.get("listGridContainer").add(grid);
      }
    
      private ListGridRecord[] getData()
      {
        ListGridRecord[] listGridRecords = new ListGridRecord[RECORD_COUNT];
        for (int i = 0; i < RECORD_COUNT; i++)
        {
          listGridRecords[i] = createRecord(i);
        }
        return listGridRecords;
      }
    
      private ListGridRecord createRecord(int i)
      {
        ListGridRecord listGridRecord = new ListGridRecord();
        listGridRecord.setAttribute("F1", new Date());
        listGridRecord.setAttribute("F2", new Date());
        listGridRecord.setAttribute("F3", new Date());
        return listGridRecord;
      }

    #2
    Use APIs on DateUtil to set formats system-wide (which will cover both grids and form controls).

    Or if they are truly field-specific, set them on your DataSourceFields.

    The MiniDateRangeItem appears automatically if you have DataSource that supportsAdvancedCriteria().

    Comment


      #3
      Thanks for fast reply!

      I can't use system-wide settings. I changed my code accordingly (i need truly field-specific formats). But still filters have their own format.

      Code:
        public static final int RECORD_COUNT = 5;
      
        public void onModuleLoad()
        {
          ListGrid grid = new ListGrid();
          grid.setDataSource(new TestDS());
          grid.setAutoFetchData(true);
          grid.setShowFilterEditor(true);
          grid.setWidth(600);
          grid.setHeight(400);
      
          RootPanel.get("listGridContainer").add(grid);
        }
      
        private class TestDS extends DataSource
        {
      
          public TestDS()
          {
            setID("localTestDS");
      
            DataSourceDateField dsField1 = new DataSourceDateField("F1", "Field 1");
            dsField1.setFormat("yyyy-MM-dd");
      
            DataSourceDateField dsField2 = new DataSourceDateField("F2", "Field 2");
            dsField2.setFormat("yyyy.MM.dd");
      
            DataSourceDateField dsField3 = new DataSourceDateField("F3", "Field 3");
            dsField3.setFormat("yyyy - MM - dd");
      
            setFields(dsField1, dsField2, dsField3);
      
            setTestData(getData());
            setClientOnly(true);
          }
      
          private ListGridRecord[] getData()
          {
            ListGridRecord[] listGridRecords = new ListGridRecord[RECORD_COUNT];
            for (int i = 0; i < RECORD_COUNT; i++)
            {
              listGridRecords[i] = createRecord(i);
            }
            return listGridRecords;
          }
      
          private ListGridRecord createRecord(int i)
          {
            ListGridRecord listGridRecord = new ListGridRecord();
            listGridRecord.setAttribute("F1", new Date());
            listGridRecord.setAttribute("F2", new Date());
            listGridRecord.setAttribute("F3", new Date());
            return listGridRecord;
          }
        }

      Comment


        #4
        Whatever i do format works only for display.

        Filter and editor ignores format.

        Comment


          #5
          We have reproduced the problem that you described, and a fix for the problem is being developed, we'll notify you as soon as this fix has been applied.

          Comment


            #6
            The fix has been just applied, so you'll find this issue fixed in the next nightly builds, dated 25th October.

            Comment

            Working...
            X