jQWidgets Forums

jQuery UI Widgets Forums Grid Not refreshing

Tagged: 

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Not refreshing #14308

    tamaraOnt
    Member

    I want to refresh a grid when I click in a button, but It doesn’t work.
    I have the following code:

    $('#refresh').click(function () {      
    var source = $('#gridUser').jqxGrid('source');
    var url =_URL_BASE_ +"/user";
    $.get(url ,{grid: true},function(result){
    var data = result['data'];
    source.localdata = data;
    $("#gridUser").jqxGrid({ source: source });
    $("#gridUser").jqxGrid('updatebounddata');
    });
    });

    If I consult the data obtained in the ajax call, I have the information updated, but the following lines of code don’t work.

    The Grid has data and works properly.

    var url = parent._URL_BASE_  +"/user";
    $.get(url ,{grid: true},function(result){
    var data = result['data'];
    var structure = result['structure'];
    var theme = 'ui-redmond';
    var source =
    {
    localdata: data,
    datatype: "array"
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    var structureColumns = formatStructure(structure);
    $('#gridUser').jqxGrid({
    width: 600,
    source: dataAdapter,
    theme: theme,
    pageable: true,
    autoheight: true,
    sortable: true,
    altrows: true,
    enabletooltips: true,
    editable: false,
    columns: structureColumns
    });
    $('#gridUser').jqxGrid('autoresizecolumns');
    });
    function formatStructure(structure){
    var structureColumns = new Array();
    var j=0;
    for (var i=0;i<structure.length; i++){
    var columns = new Object();
    columns['text']= structure[i].name;
    columns['datafield']= structure[i].name;
    columns['filtertype'] = parseFilterTypes(structure[i].type);
    if (isApplicableCellFormat(structure[i].type=="int")){
    columns['cellsformat'] = parseCellsFormat(structure[i].type);
    }
    structureColumns[j] = columns;
    j++;
    }
    return structureColumns;
    }
    Not refreshing #14314

    Peter Stoev
    Keymaster

    Hi tamaraOnt,

    You should always set the source property of jqxGrid to point to a jqxDataAdapter instance. When you click the button, you actually do not create a jqxDataAdapter.

    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.