how to start search by API call

I have search element, with suggest body, that uses custom proxy. Like this:

{
	id: "searching",
	view: "search",
	suggest: {
		keyPressTimeout: 50,
		body: {
			url: "myProxy->load.php",
			dataFeed: "myProxy->load.php"
		},
		on: {
			onValueSuggest: function (obj) {
				console.log(obj);
			}
		}
	}
}

It’s working fine with user’s manual input, but I can’t figure out how to start search in code. After I set $$(‘searching’).setValue(‘searchme’) nothing happens (obviously). I tried $$(‘searching’).callEvent(‘onkeypress’) with no effect

you should pass event args in callEvent. try this:

$$('searching').callEvent('onKeyPress', [13, null]);

Nope, same (no) effect

http://webix.com/snippet/757c0a0b

I do something like this :


{view: "search", align: "center", placeholder: "Search..", id: "search", width: 300, on: {
                                /*
                                onTimedKeyPress: function () {
                                    $$('phone-table').filter("fullname", this.getValue());
                                },
                                */
                                
                                /* on enter keypress */
                                onKeyPress: function(code,e){
                                    if(code===13){
                                        //console.log($$("search").getValue()); 
                                        // call search function
                                        searchItem($$("search").getValue());
                                    }
                                }
                            }},

and searchItem func:


var searchItem = function (val) {
        $$("phone-table").clearAll();
        var url = "yourproxy->api/v1/phone/page";
        
        var params = [];
        if (val){
            params.push("search=" + val);
        }
        
        if (params.length) {
            url = url + ((url.indexOf("?") == -1) ? "?" : "&");
            url += params.join("&");
        }
                
        //$$("phone-table").load("yourproxy->api/v1/phone/page");
        $$("phone-table").load(url);
    };

to intregal:
your efforts are much appreciated, thanks! But it’s still “not there yet”. I guess, because of proxy. See snippet http://webix.com/snippet/7b22d0e6

to finzaiko:
Thanks, looks interesting, but seems not quite what I try to achieve, can you share full snippet?

http://webix.com/snippet/e74fb4fe don’t use both url and dataFeed together. use url (if filter is clientSide) or dataFeed (if filter is serverSide). I think that in the real scenario it will work.

interesting, but it looks like real reason is not because of both url/dataFeed, but because of this string
if (!arg || !arg.filter || !arg.filter.value) return true;
for some reason proxy function receives null arg when using this “auto” call. But I need to know it’s argument for proper work.
http://webix.com/snippet/e0bab68e

try to type some text when dataFeed is provided. you will see that filter is not working. because dataFeed always returns the same.

what do you mean filter not working?
It’s not “really” filtering, cause in my snippet it’s always return same data array. In my real code there is http request with parameters from proxy argument that returns data

if you use only url, filter will work. try to type inexistent value. but if your logic is serverside, use dataFeed.