Hi guys,
I have an app with an XML view and controller.
What I need to do basically is to put a table on the view, and items with binding - however the binding filter should be dynamic.
So right now I'm having a workaround, which I have a feeling is not so great.
Is there a better way to do this than what I did?
In the controller, I can't get the table's binding, but only the binding info which I think is not recommended to use.
What I also want to avoid is to first load the data without the filter, and then put the filter.
This is what the XML view looks like:
...
<Table
id="table"
items="{
path: '/Rules',
filters: [],
sorter: {
path: 'Name',
descending: false
}
}"
growing="true"
growingScrollToLoad="true"
updateFinished="onUpdateFinished">
...
and the controller:
...
onInit : function () {
oTable = this.byId("table");
var appId = "Something not static";
var oBinding = oTable.getBindingInfo("items");
oBinding.filters = [new sap.ui.model.Filter("ApplicationId", "EQ", appId)];
...
Thanks,
Or.
Why don't you move the items declaration from the view to the controller?
Regards,
Jamie
SAP - Technology RIG
Hi,
You can do this, SAPUI5 Explored
there dynamic filter used, check the handleConfirm function in Controller file, Dialog.fragment.xml is for the filter,sorter Pop-up(do check this too)
One more thing, "In the controller, I can't get the table's binding" Why?
if you are able to get the table control, I think you should get its binding too.
Thanks,
Chandan
Or
you can declare the end point in the table (view) then on the controller event ... onBeforeRendering you can apply the filter you need (dynamically)
Add a comment