jQWidgets Forums
jQuery UI Widgets › Forums › Grid › JSONP with knockout
This topic contains 4 replies, has 2 voices, and was last updated by lev_povolotsky 11 years ago.
-
AuthorJSONP with knockout Posts
-
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.
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 StoevjQWidgets Team
http://www.jqwidgets.com/According to 3rd link
I don’t succeed to parse jsonp result.
$.parseJSON isn’t workingas 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); }); };
$.parseJSON is a jQuery function and according to me it works if you try to parse Valid JSON String.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/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?
-
AuthorPosts
You must be logged in to reply to this topic.