WelcomeForumsCommunityComboBox Remote data

Wijmo Team Member
bhoomikakaiya posted on May 28, 2012 at 1:29 pm link

Can combo box remote data be used as auto-suggest/autocomplete?

I tried like this :

var proxy = new wijhttpproxy({
url: “/Order/GetPositions/”,
dataType: “jsonp”,
data: {
featureClass: “P”,
style: “full”,
maxRows: 12
},
key: ‘p’
});

var myReader = new wijarrayreader([{
name: 'label',
mapping: function (item) {
return item.label;
}
}, {
name: 'value',
mapping: 'label'
}, {
name: 'selected',
defaultValue: false
}]);

var datasource = new wijdatasource({
reader: myReader,
proxy: proxy
});
$(“#tags”).wijcombobox({
data: datasource,
showTrigger: true,
search: function (e, obj) {
obj.datasrc.proxy.options.data.name_startsWith = obj.term.value;
},
select: function (e, item) {
// $(‘#output’).html(‘I come from ‘ + item.label + ‘!’);
}
});

HTML :

On Server :

public JsonResult GetPositions(string featureClass, string style, string maxRows)
{
List persons= new List ();
persons.Add(new Position(){label =”a”, value=”a” });
persons.Add(new Position() { label = “b”, value = “b” });
persons.Add(new Position() { label = “c”, value = “c” });
var result = new { p = persons.ToArray(), totalResultsCount=1 };
return Json( result , JsonRequestBehavior.AllowGet);
}

public class Position
{
public string label { get; set; }
public string value { get; set; }
}

I can see a call in firebug, but data it returns is in this format :

{“p”:[{"label":"a","value":"a"},{"label":"b","value":"b"},{"label":"c","value":"c"}],”totalResultsCount”:1}

Combobox remains empty.

Pl help..If needed I can post a jsfiddle too.

Thanks,
Bhoomi

Wijmo Team Member
tyler.wu posted on May 29, 2012 at 1:52 am link

Hi,
you can try the minLength option:
///

/// A value that determines the minimum length of text
/// that can be entered in the wijcombobox text box to issue an AJAX request.
/// Default: 4.
/// Type: Number.
/// Code example: $(“#tags”).wijcombobox(“option”, “minLength”, 5)
///

minLength: 4,

The default value is 4, you can set the minLength option to 1, then try the issue.

Answer

This topic has 2 voices, contains 1 reply, and was last updated by  tyler.wu 357 days ago.

You must be logged in to reply to this topic.