Announcement

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

  • Isomorphic
    replied
    We've added a DataSourceTimeField to SGWT 12.0 and newer releases. Check the latest nightly builds.

    Leave a comment:


  • Isomorphic
    replied
    Just use DataSourceField and setType() to time.

    Leave a comment:


  • mike7778
    replied
    Hi Isomorphics,
    Thanks for your help, i will try this.

    Which DataSourceField shall i use for ListGridFieldType.TIME ? I failed to found DataSourceTimeField.

    ListGridFieldType.DATETIME -> new DataSourceDateTimeField(... ,..., ...)
    ListGridFieldType.DATE -> new DataSourceDateField(... ,..., ...)
    ListGridFieldType.TIME -> ?

    Thank you.

    Leave a comment:


  • Isomorphic
    replied
    You've declared the field in the DataSource as type "datetime" but the field in the ListGrid is type "date". This doesn't make sense and the behavior is unspecified. See the Date and Time Format and Storage overview to find out how SmartGWT treats these different types.

    Leave a comment:


  • ListGrid - Date filter error with ListGridFieldType.DATE

    Hi Isomorphic,

    I use version 12.0p_2019-10-30.

    I try to use date filter.
    I have a colum with 3 dates: 10/29/2019 00:00; 10/30/2019 00:00 and 10/31/2019 00:00
    When i filter from 10/29/2019 00:00 to 10/30/2019 23:59, it's ok (i saw 10/29/2019 00:00 and 10/30/2019 00:00).

    If i specify my Date Fields as ListGridFieldType.DATE, i have 2 problems:
    1. The first time i click on the filter, i can specify Hour but when i came back to modify a date i saw only date
    2. When i filter from 10/29/2019 to 10/30/2019 i saw only 10/30/2019 (strange choice, why not 10/29/2019? (usually you include the from date and exclude the to date)).


    For reproduce, you can comment/uncomment line registeredUsersListGrid.setFields(fields); in this code:

    Code:
    class User {
    private int id;
    private String firstName;
    private Date registrationDate;
    
    public User(int id, String firstName, Date registrationDate) {
    this.id = id;
    this.firstName = firstName;
    this.registrationDate = registrationDate;
    }
    
    public int getId() {
    return id;
    }
    
    public String getFirstName() {
    return firstName;
    }
    
    public Date getRegistrationDate() {
    return registrationDate;
    }
    }
    
    private void testDateFilter() {
    SimplePanel sp = new SimplePanel();
    sp.setSize("400px", "400px");
    
    ListGridField[] fields = new ListGridField[3];
    final ListGridField listGridField1 = new ListGridField("id", "ID", 100);
    listGridField1.setType(ListGridFieldType.INTEGER);
    fields[1] = listGridField1;
    final ListGridField listGridField2 = new ListGridField("firstName", "Name", 100);
    listGridField2.setType(ListGridFieldType.TEXT);
    fields[2] = listGridField2;
    final ListGridField listGridField3 = new ListGridField("registrationDate", "Date", 100);
    listGridField3.setType(ListGridFieldType.DATE);
    fields[3] = listGridField3;
    
    DateTimeFormat format = DateTimeFormat.getFormat("MM/dd/yyyy hh:mm");
    
    User[] registeredUsers = new User[] { new User(1, "a", format.parse("10/31/2019 00:00")),
    new User(2, "b", format.parse("10/30/2019 00:00")),
    new User(3, "c", format.parse("10/29/2019 00:00")) };
    
    ListGridRecord[] registeredUsersRecords = new ListGridRecord[registeredUsers.length];
    
    for (int i = 0; i < registeredUsers.length; i++) {
    User user = registeredUsers[i];
    ListGridRecord record = new ListGridRecord();
    record.setAttribute("id", user.getId());
    record.setAttribute("firstName", user.getFirstName());
    record.setAttribute("registrationDate", user.getRegistrationDate());
    registeredUsersRecords[i] = record;
    }
    
    DataSourceDateTimeField registeredDate = new DataSourceDateTimeField("registrationDate", "Date");
    DataSourceTextField firstName = new DataSourceTextField("firstName", "Name");
    DataSourceIntegerField id = new DataSourceIntegerField("id", "ID");
    id.setRequired(true);
    id.setPrimaryKey(true);
    
    DataSource ds = new DataSource();
    ds.setClientOnly(true);
    ds.setFields(id, firstName, registeredDate);
    for (ListGridRecord registeredUsersRecord : registeredUsersRecords) {
    ds.addData(registeredUsersRecord);
    }
    
    ListGrid registeredUsersListGrid = new ListGrid();
    registeredUsersListGrid.setDataSource(ds);
    registeredUsersListGrid.setFields(fields);
    registeredUsersListGrid.fetchData();
    registeredUsersListGrid.setShowFilterEditor(true);
    
    registeredUsersListGrid.setSize("350px", "200px");
    sp.add(registeredUsersListGrid);
    RootPanel.get().add(sp);
    }
    Thanks for your help.
Working...
X