jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox Newbie Question

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Newbie Question #88714

    Wigginst
    Participant

    I’m trying to create a Listbox using a DataAdapter as my source. I have it working, however, the page is making two ajax calls. The first call is when I set my DataAdapter and the second call is when I add my source to my listBox. The problem is that I’m using displayMember and valueMember. I’ve tried all sorts of different methods to parse the JSON into a javascript array and to use that as my source, but I’ve been unsuccessful. Could someone please point me in the right direction.

    Here’s my code.

    
    var sourceSchool = { datatype: "json", datafields: [ { name: 'ProfileSchools', type: 'string' }, { name: 'numberSchools', type: 'string' } ], url: 'profile_data.asp', data: { action: 'School' } };
    var adapterSchool = new $.jqx.dataAdapter(sourceSchool, { async: false, autoBind: true, loadError: function (xhr, status, error) { alert('Error loading "' + sourceSchool.url + '" : ' + error); }});
    $("#allSchoolsBox").jqxListBox({ source: adapterSchool, selectedIndex: 0, displayMember: "ProfileSchools", valueMember: "numberSchools", filterable: true, theme: 'berkeley', allowDrag: false, allowDrop: false, width: '80%'});
    

    Thanks

    Newbie Question #88728

    Christopher
    Participant

    Hi Wigginst,

    The page is making two Ajax calls because you are using the autoBind: true property on the dataAdapter and then you are setting the dataAdapter again to the jqxListBox. You should remove the autobind from the jqxDataAdapter because it’s unnecessary. Please provide some data so we can test you code and see if there’s a problem. It shouldn’t be a problem to load the data using displayMember and valueMember from a JSON object. It doesn’t have to be a JavaScript array to do that.

    Best Regards,
    Christopher

    jQWidgets Team
    http://www.jqwidgets.com

    Newbie Question #88839

    Wigginst
    Participant

    Christopher,

    Thanks a million. Worked great.

    Wigginst

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

You must be logged in to reply to this topic.