jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox Customer Rendering with PHP and JSON issue

This topic contains 2 replies, has 2 voices, and was last updated by  andymager 12 years, 3 months ago.

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

  • vagkom
    Participant

    Hello and congratulations for this great library !

    Although I red all posts I didn’t find an answer to the following problem:

    I would like to have a custom rendering in combination with json from database. I could use your example “Custom Rendering” but the problem is that you use hardcoded data. So I tried to build the array data in order to use it later in the listbox but I get no data.

    This is my code:

    // prepare the data
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘LAST_NAME’},
    { name: ‘FIRST_NAME’},
    { name: ‘ID_PERSON’},
    { name: ‘MOBILE_PHONE’},
    { name: ‘PLATE’},
    ],
    url: ‘listboxdata.php’
    };

    var data = [];

    var dataAdapter = new $.jqx.dataAdapter(source);

    $.each(source, function(i, obj) {

    data[“LAST_NAME”]=obj.LAST_NAME;
    data[“FIRST_NAME”]=obj.FIRST_NAME;
    data[“ID_PERSON”]=obj.ID_PERSON;
    data[“MOBILE_PHONE”]=obj.MOBILE_PHONE;
    data[“PLATE”]=obj.PLATE;
    });

    $(‘#listbox’).jqxListBox(
    {
    source: dataAdapter,
    theme: ‘darkblue’,
    width: ‘100’,
    height: ‘100%’,
    selectedIndex: 0,
    displayMember: ‘LAST_NAME’,
    valueMember: ‘FIRST_NAME’,
    itemHeight: 70,
    renderer: function (index, label, value) {
    var datarecord = data[index];
    var imgurl = ‘../../images/’ + label.toLowerCase() + ‘.png’;
    var img = ‘‘;
    var table = ” + img + ” + datarecord.FIRST_NAME + ” ” + datarecord.LAST_NAME + ” + datarecord.PLATE + ”;
    return table;
    }
    });

    Thanks in advance.

    Best Regards
    Vangelis Komninos


    vagkom
    Participant

    I think I fixed.

    I use $.getJSON and then I pass the array as localdata to dataadapter and it works!

    Thanks again.

    Vag Komninos


    andymager
    Member

    Hi. I am new to jqwidjets.

    vagkom is it possible to write down All the code you used with $.getJSON .

    thank you.

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

You must be logged in to reply to this topic.