Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Filter DateField like a TextField

$
0
0
I put in dataSource object with Date type parametr:
Code:

public static DataSource createDS(List<AgentADBean> agents)
    {
        DataSource ds = new DataSource();
        ds.setClientOnly(true);
        ds.setCacheData(createRecordFromAgentAD(agents));

        ds.setFields(new DataSourceField[] {
                new DataSourceTextField(ID),
                new DataSourceTextField(NUMBER_AD),
                new DataSourceTextField(DATE)
        });
        return ds;
    }

private static Record[] createRecordFromAgentAD(List<AgentADBean> agents)
    {
        ArrayList<ListGridRecord> result = new ArrayList<ListGridRecord>();
        for (AgentADBean dogovor : agents)
        {
            ListGridRecord rec = new ListGridRecord();
            rec.setAttribute(ID, dogovor.getDover().getId().toString());
            rec.setAttribute(NUMBER_AD, dogovor.getAd().getNumber());
            rec.setAttribute(DATE, dogovor.getDover().getDate()); //type: Date
            result.add(rec);
        }
        return result.toArray(new ListGridRecord[0]);
    }

//some code to fill agentsList

final ListGrid myGrid= new ListGrid();
myGrid.setWidth(500);
myGrid.setHeight(300);
        myGrid.setShowFilterEditor(true);
        myGrid.setShowHeaderContextMenu(true);
        myGrid.setShowHeaderMenuButton(true);
        myGrid.setShowHeader(true);
        myGrid.setCanResizeFields(true);

        Button button = new Button("");
        button.setTooltip("Filter");
        myGrid.setFilterButtonProperties(button);

myGrid.setDataSource(createDS(agentsList));

ListGridField numberAd = new ListGridField(NUMBER_AD, "Code", 50);
ListGridField dateAd = new ListGridField(DATE, "Date");

myGrid.setFields(numberAd, dateAd);

if I choose the type of DataSourceDateField for my field, the filter for this column will open in a modal window over the period, but I need a simple text search.
As described above in the code search works, but the date in the cell is displayed in the format "dd.mm.yyyy" and the search is on full format "EEE, d MMM yyyy HH: mm: ss Z".

How do I change the date format in the comparison during filtration or change the filter control, if i specify the type DataSourceDateField.

I try to set DateFormatter and DateInputFormat, and DatetimeFormatter - dosn't work.

--------Info-------------
SGWT v 2.7.0
Chrome 42.0.2311.90 m

Sorry for my English is not my native language.

Viewing all articles
Browse latest Browse all 4756

Trending Articles