Forum


15:13

08/09/2008

I do:
jQuery("#list").clearGridData();
jQuery("#list").setPostData( { oper: "<%=Constantes.GENERAR_MENSAJE_LIST%>"} );
jQuery("#list").appendPostData( { desde: fechaDesdeString, hasta:fechaHastaString });
jQuery("#list").trigger("reloadGrid");
var numRecords = jQuery("#list").getGridParam("records");
alert(numRecords);
if (numRecords > 0) {
jQuery("#dataDiv").show();
} else {
alert("No se consigueron datos para las fechas dadas");
jQuery("#dataDiv").hide();
}
However numRecords comes with null value after reloadGrid (I am pretty sure there is data in my table)
So How can I check this condition ?
TIA
10:33

08/09/2008

I did it using jQuery.getJSON. Here is the code:
jQuery("#list").clearGridData();
var url = urlString + "?oper=" + "<%=Constantes.GENERAR_MENSAJE_LIST%>" +
"&desde=" + fechaDesdeString + "&hasta=" + fechaHastaString;
jQuery.getJSON(url,
function(data) {
if (data.records == 0) {
alert("No se consigueron datos para las fechas dadas");
jQuery("#dataDiv").hide();
} else {
var mygrid = jQuery("#list")[0];
mygrid.addJSONData(data);
myjsongrid = null;
jQuery("#dataDiv").show();
}
}
);
I would like to write jQuery("#list").addJSONData(data) instead of
var mygrid = jQuery("#list")[0];
mygrid.addJSONData(data);
myjsongrid = null;
Maybe in the next release 🙂
07:41

29/08/2008

HI!
I wanted to do similar thing: after reloading the grid, display the total of the rows in a separate div. The getGridParam("records") returning null as you, I've found a satisfaying solution:
I use the data type userdata to do so. In the construction of my json response I create a size value with the size of the rows being constructed. I get the value in doing
jQuery(
"#list").getGridParam('userData').size
in the loadComplete event. By the way, the ajax call being asynchronous, I must get my 'size' data in the loadComplete event and not just after the reloading of the grid.
Cordialy,
Geoffroy
06:43

Moderators
30/10/2007

Hello,
As you said there is ajax call and this call is delayed. So making
trigger("reloadGrid") and after this to get the number of reccord will give
you diffrent results.
My suggestion is to use gridComplete event - this way you will be sure
that all data is loadded and get the number of records.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
11:09

08/09/2008

I did :
gridComplete : function() {
var fechaDesde = jQuery("#list").getPostDataItem("desde");
jQuery("#dataDiv").hide();
if (fechaDesde) {
var numRecords = jQuery("#list").getGridParam("records");
if (numRecords == 0) {
alert("No se consigueron datos para las fechas dadas");
} else {
jQuery("#dataDiv").show();
}
}
}
Note the ar fechaDesde = jQuery("#list").getPostDataItem("desde");
That way I check if I am calling from reloagGrid because I added "desde" as post parameter
Best regards
02:57

Moderators
30/10/2007

Thank you Yamil
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
71 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