jQuery UI Widgets Forums Grid How to reload grid content with ajax

This topic contains 1 reply, has 2 voices, and was last updated by  ivailo 9 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • How to reload grid content with ajax #71912

    Navaneeth
    Participant

    I’m trying to call my loadgrid(ele_id)by clicking on a div which inputs the data, and it’s only working(grid displaying data) for the first time.
    from second time i’m getting data from server side but grid does’t showing any data.

    here is my sample code

    function loadgrid(ele_id){
    $.ajax({
    url: “/urlForData”,
    data:{“ele_id”:ele_id},
    dataType: ‘json’,
    beforeSend: function () {
    $(“#grid-360View”).html(”);
    },
    error: function (json, textStatus, errorThrown) {
    alert(‘ Error :’ + errorThrown);
    },
    success: function (data) {
    alert(“response: “+data);
    // initailize grid
    // alert(“data : “+data);
    var gridData = data;
    var gridSource =
    {
    localdata: gridData,
    datatype: ‘json’
    };
    var gridDataAdapter = new $.jqx.dataAdapter(gridSource);
    $(“#grid-360View”).jqxGrid(
    {
    width: ‘100%’,
    source: gridDataAdapter,
    pagesize:5,
    filterable: true,
    sortable: true,
    pageable: true,
    autoheight: true,
    altrows: true,
    enabletooltips: true,
    autoshowfiltericon: true,
    pagesizeoptions: [‘5′,’10’, ’20’, ’30’],
    editable: true,
    selectionmode: ‘singlecell’,
    columns: [
    { text: ‘Account Number’, datafield: ‘accountNumber’, width: ‘10%’ },
    { text: ‘Name’, datafield: ‘acHolderName’, width: ‘10%’ },
    { text: ‘Address’, datafield: ‘address’, width:’ 10%’ }
    ]
    });

    }
    });
    }

    How to reload grid content with ajax #71914

    ivailo
    Participant

    Hi Navaneeth,

    You are initializing the grid in every single request. That’s wrong.
    Instead you have to check when the grid is initialized, only to set the new source and then to call updatebounddata.

    Best Regards,
    Ivailo Ivanov

    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.