Praveen Chan
Praveen Chan

Reputation: 21

How to Bind custom filter value in Smart table

AS per a requirement I need to bind a custom filter bar value with the smart table. They don't want a smart filter. So I implemented the filter bar with a go button. With on click go button, I need to bind the filter value with the smart table.

My Xml Code :

<smartTable:SmartTable id="smartTable_ResponsiveTable" demandPopin="false" tableType="Table" editable="false"
    entitySet="EntitySet" showVariantManagement="true" useVariantManagement="true" useTablePersonalisation="true"
    header="Request Pending My Action" showRowCount="true" useExportToExcel="true" enableAutoBinding="true" initialise="onInitialise"
    persistencyKey="SmartTablePKey" smartVariant="pageVariantId" showFullScreenButton="true"
    initiallyVisibleFields="Vin,Acind,Bukrs,Ekorg,Zzprimary,Zzscom1,Bunit,Lifnr,Name1,Status,Uname,Credat,Cretim"></smartTable:SmartTable>

controller :

onSearch: function() {
        var Vin = new Filter("Vin", "EQ", this.getView().byId("Vin").getValue());
        var Acind = new Filter("Acind", "EQ", this.getView().byId("Acind").getValue());
        var Bukrs = new Filter("Bukrs", "EQ", this.getView().byId("Bukrs").getValue());
        var Ekorg = new Filter("Ekorg", "EQ", this.getView().byId("Ekorg").getValue());
        var Zzprimary = new Filter("Zzprimary", "EQ", this.getView().byId("Zzprimary").getValue());
        var Zzscom1 = new Filter("Zzscom1", "EQ", this.getView().byId("Zzscom1").getValue());
        var Bunit = new Filter("Bunit", "EQ", this.getView().byId("Bunit").getValue());
        var Lifnr = new Filter("Lifnr", "EQ", this.getView().byId("Lifnr").getValue());
        var Name1 = new Filter("Name1", "EQ", this.getView().byId("Name1").getValue());
        var Status = new Filter("Status", "EQ", this.getView().byId("Status").getValue());
        var Uname = new Filter("Uname", "EQ", this.getView().byId("Uname").getValue());
        var Credat = new Filter("Credat", "EQ", this.getView().byId("Credat").getValue());
        var Cretim = new Filter("Cretim", "EQ", this.getView().byId("Cretim").getValue());
        var aFilters = [];
        aFilters.push(new Filter([Vin, Acind, Bukrs, Ekorg, Zzprimary, Zzscom1, Bunit, Lifnr, Name1, Status, Uname, Credat, Cretim], true));
        var oSmartTable = this.getView().byId("smartTable_ResponsiveTable");
        oSmartTable.getTable().bindRows("/EntitySet", null, null, aFilters);

    },

Kindly provide a code to achieve this.

Upvotes: 2

Views: 5052

Answers (1)

krisho
krisho

Reputation: 1034

SmartTable works differently. Here is the Pseudocode.

onSearch: function(){
 <Get reference to SmartTable>
 <call rebindTable() API on SmartTable>
}

While defining SmartTable, attach onBeforeRebindTable to event beforeRebindTable.

onBeforeRebindTable : function(){
 <get all filters from your custom filterbar into aFilters as you did in your current code.>
 <oBindingParams.filters = aFilters>
}

Upvotes: 3

Related Questions