2016-12-19 14 views
0

私はsap.m.TableにバインドされたJSONモデルを持っています。 JSON Object Format ( "/ Date(timeStamp)")のサービスで返されるカラム "Date"(モデルのプロパティ[CreatedOn]にバインドされた)に基づいてデータをフィルタリングしようとしています。表は以下の通りです:サーバーから ​​日付/日付時刻クライアント側のフィルタJSONモデル

サンプル日:

enter image description here

私はクライアント側にテーブルをフィルタ処理しようとしていますが、私は日付のフィルタを実装する方法について確認していませんクライアント側。フィルタリング・コードは以下のように見える

:表示された日付は

sap.ui.model.type.Date({ 'DD/MM/YYYY' パターン})に基づいてフォーマットされ

var fromD = this.getView().byId("idKMFilterPaneDocDateF").getValue() ? new Date(this.getView().byId("idKMFilterPaneDocDateF").getValue()) : 
 
    undefined; 
 

 
var dtFilter = new sap.ui.model.Filter({ 
 
    path: "CreatedOn", 
 
    operator: "EQ", 
 
    value1: "dateTime'" + fromD.toJSON() + "'" 
 
}); 
 

 
var binding = oTable.getBinding("items"); 
 
binding.filter([filter], "Application"); 
 
binding.refresh();

私は上記のコードを実行すると、私はいつも "NOデータ" を取得します。私は、ユーザー選択基準に基づいて "BT"フィルターを実装する必要がありますが、それを "EQ"自体で動作させることはできません。

答えて

1

var fromD = this.getView().byId("idKMFilterPaneDocDateF").getValue() ? new Date(this.getView().byId("idKMFilterPaneDocDateF").getValue()) :undefined; 
var dtFilter = new sap.ui.model.Filter("CreatedOn"); 
dtFilter.fnTest = function(value) { 
    //check what value are you getting here. If its string, get only time out of it 
    //Compare the date values(in milliseconds) 
    fromD.setHours(0); //get rid of time and concern about date 
    fromD.setMinutes(0); 
    fromD.setSeconds(0); 
    fromD.setMilliseconds(0); 
    //value should be date object, else change accordingly.. 
    if(fromD.getTime() === value.getTime()){ 
     return true; 
    } 
    return false; 
}; 

PSをカスタムフィルタを作成します:あなたはあなたのコーディングコンテキストでJSFiddleを作業得ることができる場合、私はデバッグすることができます。

+0

ありがとうSunil、コードはチャームとして動作します:) – Deepak