jQWidgets Forums

jQuery UI Widgets Forums Grid How to load the grid with Json data at regular interval.

This topic contains 15 replies, has 2 voices, and was last updated by  kalaivani 13 years ago.

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author

  • kalaivani
    Member

    Need to load the Grid with Json data at regular interval say for every 1 minute .Any suggestion ?

    Able to load it by calling the loading function at $(“#jqxgrid”).bind(‘bindingcomplete’, function () { getdata() });

    By calling this getting an warning as The data is still binding ,call this at bind complete event .

    Thanks.


    Peter Stoev
    Keymaster

    Hi kalaivani,

    The ‘bindingcomplete’ event is raised when the binding operation is completed and the data is loaded. It is not correct to rebind the Grid in a bindingcomplete handler as this can lead to an infinite loop – binding is completed -> binding complete is raised -> rebinding in binding complete -> binding is completed -> rebinding in binding complete. If you are loading data asynchronously(default behavior), set the ‘async’ to false in the ‘source’ object initialization as this will ensure that the data is loaded when you rebind the Grid.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kalaivani
    Member

    Thanks for your reply Peter.

    Then how and where to rebind the grid in client side script ?

    Here is my code.

    function getdata()
    {
    var url = “http://" + top.location.host + “/api/kalai/Files”;
    var source =
    {
    datatype: “json”,
    datafields: [
    {name: 'Id' },
    { name: 'FileName' },
    { name: 'Link'}],
    id: “id”,
    url: url
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    $(“#jqxgrid”).bind(‘bindingcomplete’, function ()
    {
    //getProducts1();
    });
    $(“#jqxgrid”).jqxGrid(
    {
    source: dataAdapter,
    pageable: true,
    autoheight: true,
    async :false,
    columns: [
    {text: 'First Name', dataField: 'Id', width: 100 },
    { text: 'Last Name', dataField: 'FileName', width: 100 },
    { text: 'Product', cellsrenderer: makeAddToListButton_html , dataField: 'Link' }
    ]
    });
    // setInterval(“getProducts1()”, 5000);
    }
    $(document).ready(getdata);
    var makeAddToListButton_html = function (id, row, column, value) {
    var datarow = $(‘#jqxgrid’).jqxGrid(‘getcellvalue’, id, “Link”);
    return ”
    }
    function getProducts1() {
    $(document).ready(getdata);
    }
    var buttonclick = function (event) {
    var buttonID = event.target.id;
    var datarow = event.target.value;
    newwindow = window.open(datarow, ‘name’, ‘height=1000,width=1000′);
    if (window.focus) { newwindow.focus() }
    }

    How to proceed further ?


    Peter Stoev
    Keymaster

    At first, call the getData function inside the $(document).ready function as in our examples. Then set the ‘async’ to false in the source object’s initialization, not the Grid’s initialization. After the call of your getData function, create an interval and call the getData function inside the setInterval’s function body.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kalaivani
    Member

    Thanks Peter .

    It works , done as per you suggestion.You saved my time lot .Thanks .


    kalaivani
    Member

    This works fine when the project properties ->Web ->Use Visual studio Developer server.

    But its not working in Use Local IIS web server.

    i have changed my url to “http://localhost/Projapp/api/kalai/Files”; it seems to be not accessing the file.

    But the file is available at that path.

    What i need to do to work at IIS ?


    kalaivani
    Member

    hi peter ,

    Getting error on “var dataAdapter = new $.jqx.dataAdapter(source);” => unable to get value of the property ‘dataAdapter’: object is null or undefined .

    So that its not filling the Grid .

    am strucked in this .. How to solve this?

    Thanks.


    kalaivani
    Member

    Hi peter ,

    Any solution for my issue ?

    Is this because of problem in accessing the Json file ?


    Peter Stoev
    Keymaster

    According to me, the jqxdata.js is not included in your project or referenced correctly. In addition, if you are trying to fill the Grid from JSON file, the file should be on the same domain.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kalaivani
    Member

    Thanks for your reply Peter.

    I have already the Script added in my code ..

    Then the JSON file Url specified as http://localhost/JQueryGridview_demo/api/kalai/Files Where JQueryGridview_demo is the IIS website domain.
    As i said that the url specified above is have the Json file with data .but getting the Microsoft script error as unable to get value of the property ‘dataAdapter’: object is null or undefined while executing var dataAdapter = new $.jqx.dataAdapter(source);”

    For Visual studio Developer server- Url is http://localhost:portnum/api/kalai/Files -> which works fine

    I dont understd why its not working for Local IIS web server?


    Peter Stoev
    Keymaster

    Hi kalaivani,

    Sorry, but I can’t access your localhost to test what is wrong with the IIS.

    The initialization of the DataAdapter in this line var dataAdapter = new $.jqx.dataAdapter(source); should be also in a $(document).ready function.

    $(document).ready(function () {
    var dataAdapter = new $.jqx.dataAdapter(source);

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kalaivani
    Member

    Hi Peter,

    Thanks again..

    I got the solution ..

    Instead of giving static url like http://localhost/JQueryGridview_demo/api/kalai/Files or http://localhost:portnum/api/kalai/Files.

    I tried with the one below which works

    var source =
    {

    datatype: “json”,
    datafields: [
    {name: ‘Id’ },
    { name: ‘FileName’ },
    { name: ‘Link’}],
    id: “id”,
    url: ‘api/kalai/Files/’
    };

    Peter i have another one doubt -If i access this site from different system the grid view is not displaying, is this because of am using trial version of jdwidget?


    Peter Stoev
    Keymaster

    Hi kalaivani,

    You can’t access another system’s localHost. You can access your PC from a different system if you type your IP and turn off your firewall. You can refer to this post for additional details: accessing-localhost-xampp-from-another-computer-over-lan-network-how-to.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com


    kalaivani
    Member

    Yeah thats right i used IP address to access it.
    My question is grid view jqxgrid in that page alone not displaying in another system.

    Thanks.


    Peter Stoev
    Keymaster

    I don’t see a problem, If the other system’s browser is supported and is with enabled JavaScript and your page is displayed properly when it is running your PC. I am just guessing as I don’t have any information about your web page and the system’s configuration, browser, etc.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.