jQuery UI Widgets Forums Lists ComboBox combobox load from method

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 7 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • combobox load from method #86906

    fatima
    Participant

    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 Function

    but it is not work. please help me

    combobox load from method #86913

    fatima
    Participant

    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"
                });
    combobox load from method #87046

    Hristo
    Participant

    Hello fatima,

    Could you tell are there some errors messages in the console?
    Also could you try to add property async: false, in “source” of “dataAdapter” and could implement loadError(jqXHR, status, error) to the DataAdapter.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.