jQWidgets Forums

jQuery UI Widgets Forums Grid dataAdapter source.url changes but dataAdapter.cachedrecords does not

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

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

  • riegel
    Member

    Hello


    var url = '/media/search/date/2012.csv';

    var source =
    {
    datatype: "csv",
    datafields: [
    { name: 'RECORD', type: 'integer' },
    { name: 'FILEID', type: 'text' },
    { name: 'DATENUMBER', type: 'text' },
    { name: 'DATE', type: 'text' },
    { name: 'FILELENGTH', type: 'text' },
    { name: 'TITLE', type: 'text' },
    { name: 'SPEAKER', type: 'text' },
    { name: 'PASSAGE', type: 'text' },
    { name: 'SERIES', type: 'text' },
    { name: 'KEYWORDS', type: 'text' },
    { name: 'DESCRIPTION', type: 'text' },
    { name: 'AUDIOINFO', type: 'text' },
    { name: 'SERVICENAME', type: 'text' },
    { name: 'FULLPATH', type: 'text' }
    ],
    url: url
    };

    GLOBAL.source=source;

    I am changing the URL by modifying the GLOBAL.source.url, then I am changing the source for my grid like this…


    GLOBAL.source.url='/media/search/general/customsearch.csv';
    $("#jqxgrid").jqxGrid({ source: GLOBAL.source });

    It reloads the grid on screen, however my rowselect code becomes tied to the original data not the new data.


    .bind('rowselect', function (event) {
    var record=dataAdapter.cachedrecords[event.args.rowindex];
    }

    Obviously the record is getting pulled from dataAdapter.cachedrecords and should be pulled from the newest data from the new URL.

    I am confused as to how I can change the dataAdapter. The example in the docs uses a local data scenario and is hard to follow.

    Any ideas?

    Thanks,

    Terry


    Peter Stoev
    Keymaster

    Hi Terry,

    cachedrecords is an array which is used internally by our widgets. If you want to refresh the Grid’s data, use an approach like that: refreshdata.htm or create a new instance of jqxDataAdapter and set the Grid’s source property to point to it. In the jqxDataAdapter’s help documentation is also explained that when the jqxDataAdapter is loaded, the data is stored in a records array. Here’s a link to it: jquery-data-adapter.htm. The records array is refreshed when the jqxDataAdapter’s loadComplete callback function is called.

    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.