jQWidgets Forums

jQuery UI Widgets Forums Grid loadstate does not work

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 10 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • loadstate does not work #62280

    Hanno
    Participant

    hello,

    Today I have a problem with the loadstate-method for a grid.
    I save the state of a grid in a database. This works good.
    But now I will load this state and put it to the grid.
    For this I have a jqxDropdownList. If the user selects an itme in the list the state will be load from the database and the grid should change the state.

    here is the list with the states.

    url = “php_scripts/data_listen_all.php”;
    var sourceListen =
    {
    datatype: “json”,
    //async: false,
    datafields: [
    { name: ‘name_liste’ }
    ],
    url: url
    };
    var dataAdapter_listen = new $.jqx.dataAdapter(sourceListen, {
    autobind: true,
    loadComplete: function (data) {
    idx = data.length;
    //console.log(“bind “+data.length+” idx: “+idx);
    $(“#listenauswahl”).jqxDropDownList({ selectedIndex:idx, placeHolder:”Bitte Liste waehlen”, theme: theme, width:’100%’, height: ’20’, source: data, displayMember: ‘name_liste’ });
    }
    });
    dataAdapter_listen.dataBind();

    and here is the select-method

    $(“#listenauswahl”).on(‘select’, function (event) {

    var args = event.args;
    var item = $(‘#listenauswahl’).jqxDropDownList(‘getItem’,args.index);

    $.ajax({
    type: “POST”,
    url: “php_scripts/data_listen.php?item_label=”+item.label,
    //async: false,
    success: function(data) {
    var listeState = JSON.parse(data);
    //console.log(listeState);
    $(“#akzessionsliste”).jqxGrid(‘loadstate’,listeState);
    $(“#gespeichertNotification”).jqxNotification(‘open’);
    }
    });

    });

    But now it seems to me that it works only the first time. Don’t know why. The data is the same that I save to DB if i see it in firebug console. So the data will be correct I think, but I don’t know what to do to change the state from the grid.
    Can you help me, please? Perhaps you can see something wrong in my code? Thank you very very much.

    Greetings
    Hanno

    loadstate does not work #62462

    Peter Stoev
    Keymaster

    Hi Hanno,

    1. dataAdapter_listen.dataBind(); or setting autoBind to true – these are not necessary. Widgets performs binding automatically when you set the source property to point to dataAdapter.
    2. The Grid’s loadstate method is expected to be called after the Grid is ready for usage i.e in its “ready” callback function.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.