cancel
Showing results for 
Search instead for 
Did you mean: 

typeahead search using searchField

Former Member
0 Kudos

Hello,

We are creating a custom SAPUI5 master-detail application.

For master list, we have put a searchfield containing multiple filters, which works fine using oData model.

But with oData model, search string response time is slower, as it goes to back end for every search character.

We have tried with json model for the same, and it works as expected i.e. we can search the data locally.

But for json model to work, we had to attach the json model to master view, then we were able to search locally.

Can we set the oData model at launch of application to master view, and a local json model for searchField control.

I have tried with creating a json model in onAfterRendering function in master controller and setting the same model to searchField control.

But the searchField still calls the back end i.e the oData model.

Seeking help.

Regards,

Ajay Kulkarni

Accepted Solutions (1)

Accepted Solutions (1)

former_member183518
Active Participant
0 Kudos

If you don't have a huge set of data to load and want the filter to be processed in the client side, you can use V2 odata model with operationMode 'client'.


new sap.ui.model.odata.v2.ODataModel(<url>,{defaultOperationMode:"Client"});

As an alternative  instead of defining the whole model instance as Client mode, you can also specify the appropriate list binding alone in Client mode.


oList.bindItems({

                   path : "/entitySet",

                   parameters : {

                              operationMode : "Client"

                   }

});

https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.odata.v2.ODataModel.html

With this you don't have to manually create a json model from your odata just for client side filtering.

Former Member
0 Kudos

Thanks Sakthivel.

But I do have huge set of data with me.

Will the same approach work for that.

Regards,

Ajay

Answers (2)

Answers (2)

saivellanki
Active Contributor
0 Kudos

Hi Ajay,

Can you share the code of Master view and controller.

Thank you!


Regards,

Sai Vellanki.

Former Member
0 Kudos

Hi Sai,

Please find below code of master view and controller.

Master view:

Master controller:

oData model has been declared in component js file:

Regards,

Ajay

karthikarjun
Active Contributor
0 Kudos

Hi Ajay,

By default JSON model has two way binding. please change that mode to one way binding.

var oModel = new sap.ui.model.json.JSONModel();

oModel.setDefaultBindingMode(sap.ui.model.BindingMode.OneWay);

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.model.BindingMode

Thanks,

Karthik A

Former Member
0 Kudos

Thanks Karthik.

So, can I proceed with same, i.e. setting json model (oneway mode) to searchField control.

Regards,

Ajay

Former Member
0 Kudos

Hi Karthik  and Sai,

Even if I set json model to searchfield, for filtering it goes to oData model.

Can you please tell me if I am doing this set json model is correct or not.

Regards,

Ajay

Former Member
0 Kudos

@Sai Vellanki

Could you please help me in this.

Regards,

Ajay