Forum


23:19

24/09/2011

Is there a way to get the total rows and set rowNum before the grid is actually rendered? Picking an arbitrary number like 100 is fine for queries returning less than 100 records, but once those go over the rowNum limit no more records are displayed (without paging or dynamic scrolling etc).
The JSON response contains the total number of records contained in the results set, is there a way to read this and use that value to set rowNum so the grid can always display the total number of records without hitting a hard limit?
09:27

Moderators
30/10/2007

Hello,
I wonder why do you try to resolve everthing with the grid methods. You should have a very simple solution.
Create your own ajax call - this call should ask for the number of recordes (separate one)
In the succes of this ajax call construct your grid with the rowNum obtained from the request.
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.
18:09

24/09/2011

Mostly because everything I've tried so far hasn't worked. You mind giving an example.
I would have assumed according to the doc that beforeProcessing would be a trigger point to do this, but that seems to do nothing at all.
I'd prefer not to call the query a second time just to get something that's already being returned to the grid, I just can't seem to figure out where/how to read it.
03:39

24/09/2011

Tony, ok I got it sort of figured. Here's my code.
$.ajax({
type: "POST",
url: "/air/purchases/detailgrid/ponum/" + postData,
datatype: "json",
success: function (data, status) {
var tdata = data.rows;
var trows = data.records;
renderGrid(trows, tdata);
}
});
function renderGrid(trows, tdata) {
jQuery("#purchases").jqGrid({
datatype: "local",
data: tdata,
height:theight,
colNames:['Item', 'UPC', 'Description', 'Order Qty.', 'Est. Cost', 'Shipped Qty.', 'Billed Cost'],
colModel:[
{name:'item_number',index:'item_number', width:20, align:"center"},
{name:'upc',index:'upc', width:20, align:"center"},
{name:'description',index:'description', width:55},
{name:'order_quantity',index:'order_quantity', width:15, align:"center",formatter: 'integer', formatoptions:{thousandsSeparator: ",", defaultValue: '0'}},
{name:'order_unit_cost',index:'order_unit_cost', width:15, align:"center",formatter: 'currency', formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "$ "}},
{name:'shipped_quantity',index:'shipped_quantity', width:15, align:"center",formatter: 'integer', formatoptions:{thousandsSeparator: ",", defaultValue: '0'}},
{name:'shipped_unit_cost',index:'shipped_unit_cost', width:15, align:"center",formatter: 'currency', formatoptions:{decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "$ "}}
],
rowNum: trows,
rownumbers: true,
rownumWidth: 40,
pager: '#pager',
altRows: true,
altclass:'myAltRowClass',
gridview: true,
viewrecords: true,
footerrow: true,
userDataOnFooter: true,
sortorder: "asc",
autowidth: true,
shrinkToFit: true
});
}
The problem now is, the grid display with the correct number of rows, and the JSON data is there in Firebug but all the rows are empty. Any ideas what I'm doing wrong?Thanks
16:23

24/09/2011

Ok think I got it figured out… Here's the modified code of the above…
$.ajax({
type: "POST",
url: "/air/purchases/detailgrid/ponum/" + postData,
datatype: "json",
success: function (data, status) {
var tdata = JSON.stringify(data);
var trows = data.records;
renderGrid(trows, tdata);
}
});
function renderGrid(trows, tdata) {
jQuery("#purchases").jqGrid({
datatype: "jsonstring",
datastr: tdata,
…
Basically needed to convert the JSON object to a string and pass the whole thing to the grid, then tell the grid to use a JSON string. Works like a champ now.
Most Users Ever Online: 715
Currently Online:
54 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