Hi All,
I want to know about briefly filter concept.i want to know how to filter data in dialog, normally i can able to filter data in table but when i tried in dialog i'm facing little diffcult..my doubt is for example i have created one table nd then one button when i click the button dialog control open, in dialog i have created three button, when i give data it'll filter the data in table..i hope you understand my doubt..so can you please anyone clarify my doubt.
Here is my code:
var aData =[
{columns:"plants", logic:"contains", values:"160"},
{columns:"rama", logic:"krishna", values:"100"},
{columns:"alaku", logic:"contains1", values:"150"},
{columns:"kanan", logic:"contains2", values:"200"},
];
var oTable = new sap.ui.table.Table({
title: "Employees Details",
visibleRowCount: 3,
firstVisibleRow: 3,
selectionMode: sap.ui.table.SelectionMode.Single,
toolbar: new sap.ui.commons.Toolbar({items: [
new sap.ui.commons.Button({text: "Filter",
press: function() {
oController.filter();
}})
]})
});
oTable.addColumn(new sap.ui.table.Column("columns",{
label: new sap.ui.commons.Label({text: "columns"}),
template: new sap.ui.commons.TextField({value:"{columns}"})
}));
oTable.addColumn(new sap.ui.table.Column("logic",{
label: new sap.ui.commons.Label({text: "logic"}),
template: new sap.ui.commons.TextField({value:"{logic}"})
}));
oTable.addColumn(new sap.ui.table.Column("values",{
label: new sap.ui.commons.Label({text: "values"}),
template: new sap.ui.commons.TextField({value:"{values}"})
}));
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData({modelData: aData});
oTable.setModel(oModel);
oTable.bindRows("/modelData");
oTable.sort(oTable.getColumns()[0]);
oTable.placeAt("content");
}
});
Controller:
filter: function(oData) {
var oDialog1 = new sap.ui.commons.Dialog();
oDialog1.setTitle("Filter");
var oLayout = new sap.ui.commons.layout.MatrixLayout("matrix1");
oLayout.setLayoutFixed(true);
var oTxtFld = new sap.ui.commons.TextField();
var oBtn = new sap.ui.commons.Button({
text: "columns",
press: function() {
var oFilter = new sap.ui.model.Filter("columns",
sap.ui.model.FilterOperator.Contains,
sap.ui.getCore().byId("columns").getValue());
oTable.getBinding("modelData").filter(oFilter);
}
});
var oTxtFld1 = new sap.ui.commons.TextField();
var oBtn1 = new sap.ui.commons.Button({
text: "logic",
press: function() {
var oFilter = new sap.ui.model.Filter("logic",
sap.ui.model.FilterOperator.Contains,
sap.ui.getCore().byId("logic").getValue());
// oTxtFld1.getValue());
oTable.getBinding("modelData").filter(oFilter);
}
});
var oTxtFld2 = new sap.ui.commons.TextField();
var oBtn2 = new sap.ui.commons.Button({
text: "value",
press: function() {
var oFilter = new sap.ui.model.Filter("values",
sap.ui.model.FilterOperator.Contains,
sap.ui.getCore().byId("values").getValue());
// oTxtFld2.getValue());
oTable.getBinding("modelData").filter(oFilter);
}
});
oLayout.createRow(oTxtFld, oBtn,oTxtFld1, oBtn1, oTxtFld2, oBtn2);
oDialog1.addContent(oLayout);
oDialog1.open();
}
Thanks,
Visvanathan.