Forum


12:24

12/10/2010

Hi
I'm a beginner in jqgrid . when I tried to use it, I've met this problem :
I set loadonce= true, and set datatype="local", the grid is OK on the page .
and now I need to research the data from the server side and reload the grid ,
I tried some methods from internet , but doesn't work, or maybe I could not use
"loadonce = true" at this time ?
please help ....
13:34

10/08/2009

Hi
Look at this old answer. You should just reset the datatype to "local" before reloading of the grid.
Regards
Oleg
14:08

12/10/2010

Thanks for your reply ,
in fact , I've tried this, used " jQuery("#productGridView").setGridParam({ datatype: getProducts});"
to reset the datetype. but it seems that does not work on my computer, server side never receive the
postback, and the jqgrid just redraw itself , each time, at the bottom , it add the icon for "search" and "refresh",
maybe there is a conflict of JS ?
here is my code, could you please check it and tell me where is my problem ? Thanks a lot
function getProducts() {
$.ajax({
url: "Test.aspx",
data: jsonData(),
dataType: "json",
type: "POST",
success: successFunction
});
}
function dataBindToGrid() {
jQuery("#productGridView").jqGrid({
datatype: getProducts,
colNames: ['TestCol1', 'TestCol2', 'TestCol3'],
colModel: [{ name: 'TestCol1', index: 'TestCol1', width: 200, align: 'left', resizable: true },{ name: 'TestCol2', index: 'TestCol2', width: 200, align: 'left', resizable: true },{ name: 'TestCol3', index: 'TestCol3', width: 200, align: 'left', resizable: true }],
rowNum: 10,
autowidth: true,
rownumbers: true,
rowList: [5, 10, 20, 50, 100],
sortname: 'TestCol1',
pager: jQuery('#pageNavigation'),
sortorder: "desc",
viewrecords: true,
multiselect: true,
height: 50,
loadonce: true,
gridComplete: function () {
$("#productGridView").setGridParam({ datatype: 'local' });
}
});
jQuery("#productGridView").jqGrid('navGrid','#pageNavigation',
{add:false,edit:false,del:false});
}
jQuery(document).ready(function () {
jQuery("#testButton1").click(function () {
jQuery("#productGridView").setGridParam({ datatype: getProducts});
dataBindToGrid();
});
});
14:41

10/08/2009

Which version of the jqGrid you use? Could you post the test JSON data which you receive from the server (you can use Fiddler or Firebug to catch the data).
I would you not recommend to use datatype as function. If was introduced in old versions of jqGrid. Now one should use better parameters like ajaxGridOptions.
I find also a little strange, that your server page has extension aspx and not asmx (web service), svc (WCF service) or using ASP.NET MVC with no extension for the URL providing JSON data. Which technology you use on the server side to produce the JSON output? Wich version of .NET and which version of the Visual Studio you use?
If you gives more information about your server part and the jqGrid version used I'll try to post you some links with the corresponding examples.
Regards
Oleg
09:11

12/10/2010

I use the version 3.8, but maybe my example found from internet is for the old version, I use just a normal web site in Visual Studio , and use json to pass the form data to server , search the data server , and produce the Json data with the function ToJson , at last , resend the Json to client side by reponse.write :
public string ToJson(ArrayList a, int colNumber)
{ StringBuilder stringBuilder = new StringBuilder("{");
stringBuilder.Append("total: " + SurrondWithQuote(10) + ", ");
stringBuilder.Append("page: " + SurrondWithQuote(1) + ", ");
stringBuilder.Append("records: " + SurrondWithQuote(1) + ", ");
stringBuilder.Append(" rows : [ ");
for (int i = 0; i < a.Count ; i++)
{
string[] temp = a[i] as string[];
stringBuilder.Append("{");
stringBuilder.Append("id:" + SurrondWithQuote(i + 1) + ", ");
stringBuilder.Append("cell:[ ");
for (int j = 0; j < colNumber; j++)
{ if (j + 1 != colNumber)
{
stringBuilder.Append(SurrondWithQuote(temp[j]) + ", "); }
else
stringBuilder.Append(SurrondWithQuote(temp[j]));
}
stringBuilder.Append(" ]");
if (i == a.Count - 1)
{ stringBuilder.Append(" }"); }
else { stringBuilder.Append(" },"); }
}
stringBuilder.Append(" ]");
stringBuilder.Append(" }");
return stringBuilder.ToString();
}
Most Users Ever Online: 715
Currently Online:
66 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66