jQWidgets Forums

jQuery UI Widgets Forums Grid problem in binding data dynamically

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • problem in binding data dynamically #63237

    ducpm
    Participant

    Hi everyone,
    I’m using version 3.5 and trying to bind data to grid dynamically but it didn’t work as expected.

    – Initiate the grid without data
    – Click button to get data from server and bind data in the same time
    – Bind data with codes following:
    $(“#reportData”).click(function () {

    test();
    });

    function test()
    {
    var mfromDate = $(“#jqxFromDate”).val();
    var mtoDate = $(“#jqxToDate”).val();
    var getUrl = ‘@Url.Action(“rptNSDetail”, “ReportList”)’;
    $.ajax(getUrl, {

    type:’GET’,
    data: {fromDate: mfromDate, toDate: mtoDate},

    success: function(d){
    var sourceNS001 =
    {
    localdata: @Html.Raw(ViewBag.rptNS001),// Html.Raw(ViewBag.rptNS001): data received from server
    datatype: “array”
    };

    var dataAdapter = new $.jqx.dataAdapter(sourceNS001);
    dataAdapter.dataBind();
    }
    }
    }
    But nothing happened.
    Maybe I did something wrong. Please, help me! So many thanks to you.
    P.S: I’m sure of having data from server before binding data

    problem in binding data dynamically #63249

    Dimitar
    Participant

    Hello ducpm,

    You also need to re-set the grid’s source to this new instance of data adapter after dataAdapter.dataBind():

    $("#jqxgrid").jqxGrid({ source: dataAdapter });

    Best Regards,
    Dimitar

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

    problem in binding data dynamically #63265

    ducpm
    Participant

    I fixed it. Thanks so much!

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

You must be logged in to reply to this topic.