jQuery UI Widgets › Forums › Lists › ComboBox › combobox load from method
Tagged: Angular combobox, bootstrap combobox, combobox, javascript combobox, jquery combobox, jqwidgets combobox, jqxComboBox
This topic contains 2 replies, has 2 voices, and was last updated by Hristo 8 years ago.
-
Author
-
i dont know how bind combobox similar dropdown in asp.net or autocomplete by ajax
i have this code on aspx$(“#jqxcombobox”).jqxComboBox(
{
width: 200,
height: 25,
source: function (request, response) {
$.ajax({
url: “Default.aspx/LoadTest”,
data: “{ ‘parameter’: ‘t’,’maxRows’: ’20’ }”,
dataType: ‘json’,
type: ‘POST’,
async: true,
contentType: ‘application/json; charset=utf-8’,
success: function (data) {
response($.map(data.d, function (item) {
return {
id: item.value,
label: item.Name
}
}));
}
});
},
selectedIndex: 0,
displayMember: “name”,
valueMember: “value”
});and this code on .vb file
<WebMethod()>
Public Shared Function getDgsList() As List(Of AutocompleteDTO)Dim dt As New DataTable()
dt.Columns.Add(“id”, Type.GetType(“System.String”))
dt.Columns.Add(“des”, Type.GetType(“System.String”))dt.Rows.Add(New Object() {“1”, “Smith”})
dt.Rows.Add(New Object() {“2”, “Smith2”})
dt.Rows.Add(New Object() {“3”, “Smith3”})Dim PrnList As List(Of AutocompleteDTO) = dt.AsEnumerable().[Select](Function(r) New AutocompleteDTO() With {.value = r.Field(Of Integer)(“id”).ToString(), .name = r.Field(Of String)(“des”)}).ToList()
Return PrnList.Take(50).ToList()
End Functionbut it is not work. please help me
i try this
var countries = []; $.ajax({ url: "Default.aspx/LoadTest", data: "{ 'parameter': 't','maxRows': '20' }", dataType: 'json', type: 'POST', async: true, contentType: 'application/json; charset=utf-8', success: function (data) { countries = data.d; } });
and this
$("#jqxcombobox").jqxComboBox({ source: countries, width: 200, height: 25, rtl: true });
it is work but if anyone can help me to bind data by this way I would be very grateful.var source = { datatype: "json", datafields: [ { name: 'label' }, { name: 'value' }, ], url: "Default.aspx/LoadTest", data: { parameter:'t', maxRows: 50 } }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxcombobox").jqxComboBox( { width: 200, height: 25, source: dataAdapter, selectedIndex: 0, displayMember: "label", valueMember: "value" });
Hello fatima,
Could you tell are there some errors messages in the console?
Also could you try to add propertyasync: false,
in “source” of “dataAdapter” and could implementloadError(jqXHR, status, error)
to the DataAdapter.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.