jQWidgets Forums

jQuery UI Widgets Forums Grid JSONP with knockout

Tagged: , ,

This topic contains 4 replies, has 2 voices, and was last updated by  lev_povolotsky 11 years ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • JSONP with knockout #51397

    lev_povolotsky
    Participant

    Hi,

    Can anyone help me to create a grid that take the data from other source(JSONP) and to use knockout for retrieving because I’m going to retrieve more then 15000, and I don’t want the the wait logo will be for a period of time.

    I want that I will get the first data imminently and then it will continue to enrich the grid.

    Thanks in advance.

    JSONP with knockout #51416

    Peter Stoev
    Keymaster

    Hi lev_povolotsky,

    If you want to load such amounts of data, I suggest you to implement Server Paging i.e to enable the Grid’s virtualmode and to implement the rendergridrows callback function. Example: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/virtualdata.htm?arctic and http://www.jqwidgets.com/jquery-widgets-demo/demos/php/serverpaging.htm?arctic. With Knockout, make sure to use the approach with jqxDataAdapter(http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxknockout/gridwithjson.htm?arctic).

    Hope this helps.

    Best Regards,
    Peter Stoev

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

    JSONP with knockout #51467

    lev_povolotsky
    Participant

    According to 3rd link

    I don’t succeed to parse jsonp result.
    $.parseJSON isn’t working

    as you can see here in your esample

    
     var url = "../sampledata/beverages.txt";
    
                var GridModel = function () {
                    this.items = ko.observableArray();
                    var me = this;
                    $.ajax({
                        datatype: 'json',
                        url: "../sampledata/beverages.txt"
                    }).done(function (data) {
                        var jsonData = $.parseJSON(data);
                        me.items(jsonData);
                    });
                };
    
    
    JSONP with knockout #51470

    Peter Stoev
    Keymaster

    $.parseJSON is a jQuery function and according to me it works if you try to parse Valid JSON String.

    Best Regards,
    Peter Stoev

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

    JSONP with knockout #51490

    lev_povolotsky
    Participant

    but I try to parse JSONP, and founded that I shouldn’t parse it just need to insert it.

    moreover I succeed to load the data into me.items(data) and it’s works.

    The issue now that it doesn’t repreasnt me the data and I don’t know why

    I use exactly these code but diffrent columns and it doesn’t represnt me it and I don’t have any error
    `
    var model = new GridModel();
    // prepare the data
    var source =
    {
    datatype: “observablearray”,
    datafields: [
    { name: ‘name’ },
    { name: ‘type’ },
    { name: ‘calories’, type: ‘int’ },
    { name: ‘totalfat’ },
    { name: ‘protein’ },
    ],
    id: ‘id’,
    localdata: model.items
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    $(“#grid”).jqxGrid(
    {
    width: 670,
    source: dataAdapter,
    columns: [
    { text: ‘Name’, datafield: ‘name’, width: 250 },
    { text: ‘Beverage Type’, datafield: ‘type’, width: 250 },
    { text: ‘Calories’, datafield: ‘calories’, width: 180 },
    { text: ‘Total Fat’, datafield: ‘totalfat’, width: 120 },
    { text: ‘Protein’, datafield: ‘protein’, minwidth: 120 }
    ]
    });
    ko.applyBindings(model);
    `

    Do you know why it’s happened?

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

You must be logged in to reply to this topic.