jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Problem with page Load (PageMethods & Grid ) Asp.Net
Tagged: ASp.Net Grid jQ
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 11 years, 11 months ago.
-
Author
-
i have a basic issue that
open Default.aspx and Grid Load With data and a refresh button refresh grid data.
there is no problem refresh button but i couldnt make load grid during pageload ?getList(); function is working after page load so my grid is not seems loaded ?
how do i solve this issue, i hope i could explain my point
Thanks.
var datares = new Array();
function getList()
{
GreetingsFromServer();
return datares;
}function GreetingsFromServer()
{
PageMethods.getList2(OnSuccess, OnError);
return false;
}
function OnSuccess(response)
{
var data = new Array();
var k = 0;
for (var i = 0; i < response.length; i++) {
var row = {};
row["id"] = response[i].id;
row["firstname"] = response[i].Name;
row["lastname"] = response[i].Surname;
data[i] = row;
k++;
}
datares = data;
}function OnError(error)
{
debugger;
alert(error);
}$(document).ready(function()
{
getList();
var theme = getDemoTheme();
var source ={
localdata: datares,
datafields:
[
{ name: 'id', type: 'string' },
{ name: 'firstname', type: 'string' },
{ name: 'lastname', type: 'string' }
],
datatype: "array"
};var dataAdapter = new $.jqx.dataAdapter(source);
var columns = [
{ text: 'ID', dataField: 'id', width: 100 },
{ text: 'First Name', dataField: 'firstname', width: 100 },
{ text: 'Last Name', dataField: 'lastname', width: 100 }
];$("#grid").jqxGrid(
{
width: 500,
height: 300,
source: dataAdapter,
theme: theme,
columns: columns,
pageable: true,
autoheight: true,
sortable: true
});// init buttons.
$("#refresh").jqxButton({ theme: theme });
$("#clear").jqxButton({ theme: theme });$("#refresh").click(function()
{
source.localdata = getSonData();
$("#grid").jqxGrid('updatebounddata', 'cells');
});$("#clear").click(function() {
$("#grid").jqxGrid('clear');
});$("#refresh").click(function()
{
source.localdata = getSonData();
$("#grid").jqxGrid('updatebounddata', 'cells');
});});
Hi,
I suppose that at the point the page is loaded, your “datares” variable is an empty array. You have 2 solutions here – use the jqxDataAdapter plug-in for handling the Ajax calls or make the calls to your server synchronous.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.