jQuery UI Widgets Forums Lists ListBox Listbox doesn't populate from mysql with php

This topic contains 4 replies, has 2 voices, and was last updated by  branko7171 11 years, 10 months ago.

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

  • branko7171
    Member

    Hello,
    I’m sorry if I’m posting this in the wrong forum.
    I’m trying to populate a listbox with data from a mysql database. The data is returned from a php file called “problemiOblastData.php” as JSON. The problem is that no data is shown in the listbox.
    Now, I’ve discovered that when I change my query string in php file the listbox shows some data.
    Original query (not working) is this:

    $query = "SELECT P.ImeDatoteke,P.ProblemId
    FROM problem P P,problempripadaoblasti PPO, oblast O
    WHERE P.ProblemId = PPO.ProblemId AND PPO.OblastId=O.OblastId

    And then I change to this:

    $query = "SELECT P.ImeDatoteke,P.ProblemId
    FROM problem P";

    Source for the listbox:

    var source4 =
    {
    async: false,
    datatype: "json",
    datafields: [
    { name: 'id'},
    { name: 'text' }
    ],
    id: 'id',
    url: 'problemiOblastData.php',
    processdata: function (data) {
    data.selectedOblast = $('#problemiTree').jqxTree('getSelectedItem');
    if (data.selectedOblast && data.selectedOblast.parentId != 0) data.selectedOblast = data.selectedOblast.id;
    else data.selectedOblast = "0"; // ako nista nije selektovano, ili je selektovan predmet
    // alert(data.selected);
    }
    };

    Adapter for the listbox:

                    var dataAdapter4 = new $.jqx.dataAdapter(source4);
    $("#jqxlistbox2").jqxListBox(
    {
    source: dataAdapter4,
    theme: 'classic',
    width: 200,
    height: 250,
    displayMember: 'text',
    valueMember: 'id'
    });

    I’m binding the data with:

    $('#problemiTree').bind('select', function (event) {
    //var item3 = $('#problemiTree').jqxTree('getSelectedItem');
    //if (item3 && item3.parentId!=0)
    dataAdapter4.dataBind();
    //alert(item3.parentId);
    });

    I can provide the php code if you think that’s relevant.


    Peter Stoev
    Keymaster

    Hi branko7171,

    Unfortunately, I don’t know what might be the issue from the provided Server and Client side Script. I suggest you to try the jqxDataAdapter’s loadComplete, downloadComplete and loadError callback functions to see whether any data comes at all to the client.
    For binding a ListBox to MySQL Database, you can take a look at the demo included in the phpdemos folder in the download package.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    branko7171
    Member

    I’ll try that. Thanks.
    Edit: I’m already echoing JSON and checking by a direct link to the php file. Everything seems to be in order because JSON data is there.
    That confirms that data really is getting to the client, right?


    Peter Stoev
    Keymaster

    Hi branko7171,

    Yes, now you should make sure that the data is loaded in the jqxDataAdapter’s loadComplete callback.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    branko7171
    Member

    Sorry about not letting you know (forgot about this post, since I’ve made a bunch), but I’ve figured it out. It works fine now, thank you.

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

You must be logged in to reply to this topic.