Make template parameter optional for sap.ui.base.ManagedObject.bindAggregation
This is an improvement request:
According to this discussion on SCN I want to request this improvement of sap.ui.base.ManagedObject.bindAggregation.
For me it would make sense to make the template parameter for this method optional.
In my use case I have a large and expensive to retrieve entityset in my ODataModel. On a page of my application I have some input controls for the user to enter some filters and then a sap.m.table to display the query results.
I define my views as XML views. The table with its template for the items is also defined there.
<Table
id="EquiTable"
items="{/EquipmentSet}">
<columns>
...
</columns>
<items>
<ColumnListItem type="Active">
<cells>
...
</cells>
</ColumnListItem>
</items>
</Table>
In the controller I need to create/change the binding of the items aggregation of the table when the user changes the filter values.
Calling sap.m.table.bindItems I must provide a template otherwise the call fails with an exception.
To accomplish what I need to do I have to retrieve the template in my controller's onInit method and remember it for later use.
var oTableEqui = this.getView().byId("EquiTable");
this.oTemplateEqui = oTableEqui.getBindingInfo("items").template;
When changing the binding I pass the remembered template to the bindItems method:
oTableEqui.bindItems({
path : "/EquipmentSet",
template : this.oTemplateEqui,
filters : aFilters,
sorter : this.aSorterEqui
});
This overhead of retrieving and storing the template object is unnecessary in my oppinion. If there are better solutions or other points which I may not have considered, please explain these.
Thank you for your efforts in continuously improving this great framework!
I second the above request ... I had exactly the same issue ...
The general trend within UI5 development seems to be the usage of XML views ( as said eg in the openSAP HANA XS delta course ) ... hence the ability to easily update the table binding without having to fall back to manual JS template creation or upfront storage is a must ...
Thanks,
Steven
Hi,
thanks for reporting this requirement! I will inform the responsible team and they will let you know if they put it on their requirements list.
Kind regards, Janina
What about just using the filter-method on the binding, instead of creating a new binding every time?
oTableEqui.getBinding("items").filter(aFilters)
Regards, Malte
Hi Goligo / All,
Thanks for the remark ... If we just wanted to apply 'filtering as such' then indeed this would be a simple solution ... but the 'problem' is more profound - as discussed on the SDN topic - basically we have an ODATA service which is quite 'expensive' in terms of data gathering ... We want to use XML views for the declaration of the control but if we declare the binding upfront in the XML view then the ODATA model will automatically execute the binding and perform as such an expensive call while we don't want that ( can't remember if it is only the count call or both and I know you can disable the count but I actually want those as well ) ... We actually only want the call to happen when the user has applied the necessary filtering ( which will always happen ) or otherwise put we want to chose the exact moment when we let the binding tringger the call while still being able to define everything in the XML view ... so far the only way to achieve this is to resort back to creating the binding at a later stage ... where you are now obliged to add the item template ...
Hope this helps in claryfing the 'issue' ...
Thanks,
Steven
but if we declare the binding upfront in the XML view then the ODATA model will automatically execute the binding and perform as such an expensive call while we don't want that
This exactly. :+1: for this request.
Any update on this @blaesius @goligo ?
This Topic is obsolet. The Discussion on SAP "Getting the item template of a m.Table" https://archive.sap.com/discussions/message/16232197#16232197 is answered in Stack Overflow https://stackoverflow.com/questions/49536743/missing-template-or-factory-function-for-aggregation-items-of-element-while-bi/49538734#49538734?newreg=a6980a794e754ced8f4a670f1296bbdc
Hi @Frank683 , I'll close the issue. @mhpmahu already posted an answer for that. All the best, Florian