Announcement

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

    Date range filter in Grid

    Hi Team i am using smart gwt 6.1p evaluation version with gwt 2.6.1 for filter List grid . The method which is used is listGrid.setShowFilterEditor(true); Date format in List grid Date field is MM/dd/yyyy.
    But for some reason its not working other filter are working fine . Please let me know what could be the reason for this. code snippet is below.
    DataSource searchDetailGridResultDS = new SearchDetailGridResultDS("SearchDetailGridResultDS", lsFields, lstSearchResult);
    searchDetailGridResultDS.setClientOnly(true);

    lstInmateResults = new ListGrid();
    lstInmateResults.setShowRecordComponents(true);
    lstInmateResults.setShowRecordComponentsByCell(true);
    lstInmateResults.setShowAllRecords(true);
    lstInmateResults.setCellHeight(60);
    lstInmateResults.setPadding(3);
    lstInmateResults.setCellPadding(5);
    lstInmateResults.setHeaderHeight(35);

    lstInmateResults.setHeaderBackgroundColor("#4F80BC");
    lstInmateResults.setHeaderBaseStyle("listGridHeaderStyle");
    lstInmateResults.setHeaderTitleStyle("listGridHeaderTitleStyle");
    lstInmateResults.setFixedRecordHeights(true);
    lstInmateResults.setHeight100();

    lstInmateResults.setShowHeaderContextMenu(false);
    lstInmateResults.setLeaveScrollbarGap(false);
    lstInmateResults.setSelectionType(SelectionStyle.SINGLE);
    lstInmateResults.setEditByCell(true);
    lstInmateResults.setCanSort(true);
    lstInmateResults.setSortDirection(SortDirection.DESCENDING);
    lstInmateResults.setAlternateRecordStyles(true);
    lstInmateResults.setAutoFitData(Autofit.VERTICAL);
    lstInmateResults.setShowFilterEditor(true);
    lstInmateResults.setExportAll(true);
    lstInmateResults.setDataSource(searchDetailGridResultDS);
    lstInmateResults.setAutoFetchData(true);
    ListGridField[] fields = new ListGridField[lsFields.size()];
    for (int i = 0; i < lsFields.size(); i++) {
    SearchGridField searchGridField = lsFields.get(i);

    fields[i] = new ListGridField(searchGridField.getId(), searchGridField.getTitle());
    fields[i].setWidth(searchGridField.getWidth());
    fields[i].setCanSort(searchGridField.isSorting());

    if (searchGridField.getType().equalsIgnoreCase("string")) {
    fields[i].setType(ListGridFieldType.TEXT);
    } else if (searchGridField.getType().equalsIgnoreCase("date")) {
    fields[i].setType(ListGridFieldType.DATE);
    fields[i].setCanFilter(true);
    fields[i].setFormat("MM/dd/yyyy");

    } else if (searchGridField.getType().equalsIgnoreCase("number")) {
    fields[i].setType(ListGridFieldType.INTEGER);
    } else if (searchGridField.getType().equalsIgnoreCase("float")) {
    fields[i].setType(ListGridFieldType.FLOAT);
    } else if (searchGridField.getType().equalsIgnoreCase("boolean")) {
    fields[i].setType(ListGridFieldType.BOOLEAN);
    }

    }

    fields[lsFields.size() - 1].setWidth("*");
    lstInmateResults.setFields(fields);




    #2
    Please clarify "it's not working".

    One clear mistake above is that you've changed the display format but not also set the input format to match. Note also that this is typically done system-wide via APIs on DateUtil, to avoid having to reiterate the format in every UI control you create.

    Also note, when posting, you need to post your full version, not just 6.1p (see FAQ).

    Comment


      #3
      Thanks Team, It worked now all i did is to set the input format DateTimeFormat dateFormat = DateTimeFormat.getFormat("MM/dd/yyyy");
      record.setAttribute(entry.getKey().toLowerCase(), (entry.getValue() != null) && !entry.getValue().isEmpty() ? dateFormat.parse(entry.getValue()) : ""); :)

      Comment

      Working...
      X