How to configure dataFeed and server-side filtering for ui.suggest?

391 views Asked by At

I'm following this sample to create a suggest control attached to text field:

webix.ui({
  view: "suggest",
  input: $$("testText"),
  body:{
    dataFeed:"/data.php"
  }
});

The datafeed property sends the request to the server and returns the filtered data. Th request is

"data.php?filter[value]=Ar"  // where 'Ar' is a typed text

But what if I need to limit the minimal number of typed symbols to send the request? For example, I want to reload the data when more than 3 characters are typed.

It possible or do I need to write my own method? How to do that?

Thanks in advance for any hint.

1

There are 1 answers

1
fabien-michel On BEST ANSWER

This seems not to be trivial, I found this solution on the webix forum :

body:{
    dataFeed: function(filtervalue){
        if(filtervalue.length<3) return;
        var urldata = "filter[value]="+encodeURIComponent(filtervalue);
        this.load("http://docs.webix.com/samples/13_form/01_controls/server/data.php?"+urldata, this.config.datatype);
    }
}

Demo snippet : http://webix.com/snippet/4019c87a