on 12-15-2016 11:02 PM
I created a custom control on a smart filter bar. I am unsure of how to pass the selection to the server so it updates the filter and rebinds the data to the smart table. Here is the custom smartfilter bar:
<smartFilterBar:ControlConfiguration groupId="_BASIC" key="ZQ_STAT" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false" >
<smartFilterBar:customControl>
<Select id="qualStatusDropDown" change="onQualSearch">
<core:Item key="" text=" " />
<core:Item key="0" text="0" />
<core:Item key="1" text="ONE" />
<core:Item key="2" text="TWO" />
<core:Item key="3" text="THREE" />
</Select>
</smartFilterBar:customControl>
</smartFilterBar:ControlConfiguration>
Here is the code I am using in the controller:
onQualSearch : function (oEvent) {
var oTableSearchState = [];
var sQuery = oEvent.getSource().getProperty("selectedKey");
oTableSearchState = [new Filter("ZQ_STAT", FilterOperator.EQ, sQuery)];
this._applyFilter(oTableSearchState);
//MessageToast.show("You picked " + sQuery);
},
_applyFilter: function(oTableSearchState) {
var oTable = this.byId("gSmartTable");
//oTable.getBinding("items").filter(oTableSearchState, "Application");
}
I used this code on a standard table and search field, but I am getting an error in the console stating 'getBinding' is not a function. I assume this is because that function does not exist in the smarttable controller.
Can anyone assist with what to do next?
Cheers,
Tim
Hi Tim,
oTable.getBinding() function doesn't exist for smart table. You can use oTable.rebindTable() and write your filtering logic code in onBeforeRebindTable() function as displayed in the following lines:
<smartFilterBar:ControlConfiguration groupId="_BASIC" key="ZQ_STAT" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false">
<smartFilterBar:customControl>
<Select id="qualStatusDropDown" change="onQualSearch">
<items>
<core:Item key="0" text="0" />
<core:Item key="1" text="ONE" />
<core:Item key="2" text="TWO" />
<core:Item key="3" text="THREE" />
</items>
</Select>
</smartFilterBar:customControl>
</smartFilterBar:ControlConfiguration>
and in your controller file:
onQualSearch : function (oEvent) {
this.oTableSearchState = [];
var sQuery = oEvent.getSource().getProperty("selectedKey");
oTableSearchState = [new Filter("ZQ_STAT", FilterOperator.EQ, sQuery)];
this._applyFilter(oTableSearchState);
//MessageToast.show("You picked " + sQuery);
},
_applyFilter: function(oTableSearchState) {
var oTable = this.byId("gSmartTable");
oTable.rebindTable(); // Call rebindtable function here
},
onBeforeRebindTable: function(oEvent) { //Add this function to your controller
this.mBindingParams = oEvent.getParameter("bindingParams");
this.mBindingParams.filters = this.oTableSearchState;
}
Hope this helps 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.