cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SearchField limits?

bjorn-henrik_zink
Contributor
0 Likes
1,722

Hi,

I am using the SearchField to swiftly filter values in a large list. The list initially had 1023 entries and it worked fine. Now, the list has grown to 9963 entries and it has stopped working. Are there any SearchField limits? If yes, what are they?

Thanks!

Accepted Solutions (0)

Answers (2)

Answers (2)

bjorn-henrik_zink
Contributor
0 Likes

Update - I have now found the problem. It has nothing to do with the number of entries. The problem occurs when the column data from the model contains numbers only, for example 3026.

Question, how can I force the binding to be of type String for my column?

fredericorocha
Explorer
0 Likes

You can achieve that by using a formatter where you convert int to string.

Regards,

Frederico

bjorn-henrik_zink
Contributor
0 Likes

Hi Frederico,

thanks for your reply. As you can read above I have used a Formatter in the view (when setting the value of the control). It did not work, but I will try again. Perhaps, I should do it ealier in the code, e.g. in the controller. Where in the code would you add the Formatter call?

fredericorocha
Explorer
0 Likes

Hi Bjorn,

It should be in the view. Sorry first time I didn't see you were already using. However I think you should do it like this:

  1. new sap.m.Text({text:"{ 
  2.                                    path:'Weight'
  3.                                    formatter: function(v){ 
  4.                                    return v.toString(); 
  5.                                    } 
  6.                               }" 
  7.                          }); 



Regards,

Frederico

bjorn-henrik_zink
Contributor
0 Likes

Hi Frederico,

as I mentioned above, it does not seem to work for me. I use XML:


<StandardListItem

  title="{path: 'someTitle', type : 'sap.ui.model.odata.type.String'}"

  description="{path: 'someDesc'}"

  type="Navigation"

  press="onSearchListItemPressed"

  iconDensityAware="false"

  iconInset="false"/>

Other option I have tried is using a custom formatter:


<StandardListItem

  title="{path: 'someTitle', type : 'formatter: 'zink.utils.StringFormatter.stringFormat''}"

  description="{path: 'someDesc'}"

  type="Navigation"

  press="onSearchListItemPressed"

  iconDensityAware="false"

  iconInset="false"/>

The code of my custom formatter, StringFormatter.js looks like this:


sap.ui.define([

        'sap/ui/model/type/String'

], function (String) {

  "use strict";

  var StringFormatter = {

  stringFormat : function (v) {

  return v.toString();

  }

  };

  return StringFormatter;

}, /* bExport= */ true);

Anyway, it seems that the type change is done too late and therefore it has not impact on the filter. I would like to force the data type when binding the model, but I am not sure how to do that ...

SergioG_TX
SAP Champion
SAP Champion
0 Likes

Bjorn,

is the column data type varchar ?

did you try changing the sQuery to sQuery.toString()  ? even on your liveChange event, what if you type a number.. does it stay as a string?

bjorn-henrik_zink
Contributor
0 Likes

Hi Sergio,

yes, the column data type is varchar.

sQuery is also a string when entering numbers in the search field, i.e. the problem resides in the list data.

fredericorocha
Explorer
0 Likes

Is it getting inside of your custom formatter? Please make a breakpoint and make sure that is getting inside of the stringFormat function.

Regards,

Frederico

bjorn-henrik_zink
Contributor
0 Likes

Yes, the function is reached. As mentioned earlier in this thread, I have even changed all the vakues to "test", but that did not change the issue from occuring, which is why I want to change the data before binding of the values and then adding to the filter.

A far thought, could two-way binding perhaps help ...?

bjorn-henrik_zink
Contributor
0 Likes

Two-way binding seems to be the default so that can not be the solution either.

fredericorocha
Explorer
0 Likes

My suggestion here would be to create a local model. On this local model you should already convert all your numbers in strings and then proceed with the bindings and filters.

Regards,

Frederico

bjorn-henrik_zink
Contributor
0 Likes

The error message I get is: Only "String" values are supported for the FilterOperator: "Contains". It leads me to think that it might be related to the data and not the volume.

How can I force the binding to be of type string of my model data for a specific column?

Here is my present code:


// filter list binding

var list = this.getView().byId("myList");

var binding = list.getBinding("items");

binding.filter(myFilters, "Application");

Thanks!

saivellanki
Active Contributor
0 Likes

Hi Bjorn,

Use a formatter, consider you have text as template (Just for an example, even though text is of string type):


new sap.m.Text({text:"{

                                   path:'Weight',

                                   formatter: function(v){

                                   return String(v);

                                   }

                              }"

                         });

Regards,

Sai Vellanki.

bjorn-henrik_zink
Contributor
0 Likes

Hi Sai,

thanks, we both had the same thought and I have now tested using a formatter. In fact, I replaced all the strings with "Test" and it results in the same error, i.e. it has nothing to do with the actual values and must be something with the size of the list. I will dig a bit further and keep the thread posted.

SergioG_TX
SAP Champion
SAP Champion
0 Likes

Bjorn,

can you post your code on how you created the filters as well? I am suspecting the issue being with the filter itself and maybe not necessarily with the binding

bjorn-henrik_zink
Contributor
0 Likes

Hi Sergio,

thanks for your reply, here is the filter code, hope you find something fishy or can help me force the column to be of type string:


var aFilters = [];

var sQuery = oEvt.getSource().getValue();


if (sQuery && sQuery.length > 0) {

       var filter = new Filter("someColumnName", sap.ui.model.FilterOperator.Contains, sQuery);

       aFilters.push(filter);

}

// Update list binding with filter

var list = this.getView().byId("searchList");

var binding = list.getBinding("items");

binding.filter(aFilters, "Application");

SergioG_TX
SAP Champion
SAP Champion
0 Likes

line 10...

binding.filter(aFilters); // try using this line instead of what you have

bjorn-henrik_zink
Contributor
0 Likes

I tried the code change, but no difference, the error persists 😞

SergioG_TX
SAP Champion
SAP Champion
0 Likes

in the chrome dev tools.. what is the value of sQuery ?

if not a string.. do.. sQuery.toString()... try this and see what happens next?

bjorn-henrik_zink
Contributor
0 Likes

Hi Sergio,

I've got liveChange on the search field and the entry is a string. Here's an example: