oData model binding - Suspend initial data load

Sometimes we may want to suppress the initial data load of the oData binding in our controls. For example, we may want to display a list of employees for a given department. Since the department gets selected after the employee list binding is completed, the standard behaviour of our list binding would be to try and load all employees after the page is initialized.

We can suppress this initial load of all the data with the 'suspended' property of the oData model binding like so:

<List
    id="employeeList"
    headerText="Employees"
    items="{
        path: '/Employees',
        suspended: true
    }" >
    <StandardListItem
        title="{Name}"/>
</List>

Now the employee list will not be loaded when the view is initialized. We can resume the binding manually by calling the resume method like so:

var oBinding = this.byId("employeeList").getBinding("items");

oBinding.resume();

The binding will also be resumed by any operation that refreshed the binding completely, such as filter:

var oBinding = this.byId("employeeList").getBinding("items");

oBinding.filter("Department", "EQ", "HR");
oData model binding - Suspend initial data load
Share this