jQWidgets Forums

jQuery UI Widgets Forums Grid autosavestate and autoloadstate destroy ?

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

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

  • punkrack
    Participant

    Hi!

    Is there a way to destroy what autosavestates ‘creates’ ?

    It’s because for example, I have :

    // initialize jqxGrid $(“#jqxgrid”).jqxGrid( {       width: ‘100%’,     source: dataadapter,     theme: jqw_theme,     selectionmode: ‘multiplerows’,     autosavestate: true,     autoloadstate: true,

     

    I click a link and initialize jqxgrid above. I use filtering and sorting on that grid.

    I click another link which calls the same script to initilize the grid, but the grid’s content is suppose to be different (the query goes …AND WHERE some_condition = X in the first place, but the second time, same query but … AND WHERE some_condition = Y)

    But since I autosavestate, on page/grid load, it puts me the content that was autosaved if it has common content or crashes if query results no content.

    I don’t know if it’s clear enough…

    Thanks !


    Peter Stoev
    Keymaster

    Hi punkrack,

    “autosavestate” and “autoloadstate” purpose it to automatically save and load the Grid’s state. If you wish to do that manually, then do not turn on these settings and use the Grid’s “savestate” and “loadstate” methods. In addition, if you just want to change the Grid’s content, do not initialize it again, just set its “source” property to point to a new instance of “jqxDataAdapter”.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/


    punkrack
    Participant

    Hi!

    I put 2 buttons just like in the demo “save state” and “load state”. Attached to these buttons are 2 functions :

    function saveState() {
    state = $(“#jqxgrid”).jqxGrid(‘savestate’);
    }

    function loadState() {
    if (state) {
    $(“#jqxgrid”).jqxGrid(‘loadstate’, state);
    }
    else {
    $(“#jqxgrid”).jqxGrid(‘loadstate’);
    }
    }

    When I press loadState after saveState to test, I get this javascript error:

    Error: jqxGrid: The data is still loading. When the data binding is completed, the Grid raises the ‘bindingcomplete’ event. Call this function in the ‘bindingcomplete’ event handler. [http://colligetest.ccdmd.qc.ca/js/jqwidgets/jqxgrid.filter.js:7]

    Here is my grid code :

    var state = null;
    var source =
    {
    datatype: "json",
    datafields: [
    { name: 'chk_box', type: 'string'},
    { name: 'titre_fiche', type: 'string'},
    { name: 'titre_modele', type: 'string' },
    { name: 'type_acces', type: 'string' },
    { name: 'date_modification', type: 'date' },
    { name: 'suivi', type: 'string' }
    ],
    cache: false,
    url: baseURL + '/collections/mes-collections/selectionner-fiches-collection',
    filter: function()
    {
    // update the grid and send a request to the server.
    $("#jqxgrid").jqxGrid('updatebounddata', 'filter');
    },
    sort: function()
    {
    // update the grid and send a request to the server.
    $("#jqxgrid").jqxGrid('updatebounddata', 'sort');
    },
    root: 'Rows',
    beforeprocessing: function(data)
    {
    if (data != null)
    {
    source.totalrecords = data[0].TotalRows;
    }
    }
    };
    var dataadapter = new $.jqx.dataAdapter(source, {
    loadError: function(xhr, status, error)
    {
    alert(error);
    }
    }
    );
    // initialize jqxGrid
    $("#jqxgrid").jqxGrid( {
    width: '100%',
    source: dataadapter,
    theme: jqw_theme,
    selectionmode: 'multiplerows',
    autosavestate: false,
    autoloadstate: false,
    filterable: true,
    sortable: true,
    pageable: true,
    columnsresize: true,
    autoheight: true,
    virtualmode: true,
    showdefaultloadelement: false,
    pagesizeoptions: jqw_pagesizeoptions,
    rendergridrows: function(obj)
    {
    return obj.data;
    },
    ready: function()
    {
    },
    columns: [
    { text: '', datafield: 'chk_box', sortable: false, filterable: false, editable: false, width: '5%',
    renderer: function () {
    return '<div></div>';
    }
    },
    { text: 'TITRE', datafield: 'titre_fiche', width: '45%' },
    { text: 'MODÈLE', datafield: 'titre_modele', width: '15%' },
    { text: 'ACCÈS', datafield: 'type_acces', width: '10%' },
    { text: 'DATE MODIFICATION', datafield: 'date_modification', filtertype: 'date', editable: false, cellsalign: 'left', cellsformat: 'd MMMM yyyy, HH:mm', width: '20%' },
    { text: '', datafield: 'suivi', sortable: true, filterable: false, editable: false, width: '5%',
    renderer: function () {
    return '<div></div>';
    }
    },
    ]
    });

    What am I doing wrong here ? It should be simple….
    Please help… :/

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

You must be logged in to reply to this topic.