Skip to Content
avatar image
Former Member

typeahead search using searchField

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 12, 2015 at 06:20 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 12, 2015 at 04:36 AM

    @Sai Vellanki

    Could you please help me in this.

    Regards,

    Ajay

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 12, 2015 at 05:16 AM

    Hi Ajay,

    Can you share the code of Master view and controller.

    Thank you!


    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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