我已经将来自服务器的数据显示到 jqgrid 中。现在根据我的需要,我必须为每组数据启用带有摘要页脚的分组,但我不知道如何在 JQGRID 中实现这一点。我使用 JSP 作为服务器端代码从数据库中获取数据。获取数据后,我手动转换为 JSON 类型..
这是我的客户端代码..
var i=1;
$('#go').click(function(evt){
evt.preventDefault();
fromdate=$('#fromdate').val();
todate=$('#todate').val();
if(fromdate && todate)
{
var URL='getGriddahico.jsp';
if(i==1){gridcall(URL);}
else{jQuery("#gridUsuarios").jqGrid('GridUnload');gridcall(URL);}
i++;
}
});
});
function gridcall(path)
{
jQuery("#gridUsuarios").jqGrid({
url:path,
datatype: "json",
colNames:['ID','Call Date','Call Time','Source','DialedNo','Extension'],
colModel:[
{name:'id',index:'id', width:90,align: 'center',editable:true, hidden:true,closed:true},
{name:'date',index:'date',editable:false, width:150,align: 'center'},
{name:'time',index:'time',editable:false, width:150,align: 'center'},
{name:'source',index:'source',editable:false, width:170,align: 'center'},
{name:'destination',index:'destination',editable:false, width:170,align: 'center'}
],
rowNum:50,
rowList:[50,100,150],
scrollrows : true,
pager: '#pagGrid',
sortname: 'id',
viewrecords: true,
sortorder: "asc",
autowidth:true,
toppager: true,
height:470
});
// Set navigator with search enabled.
jQuery("#gridUsuarios").jqGrid('navGrid','#pagGrid',{cloneToTop:true,add:false,edit:false,del:false,search:false})
这是我的jsp代码,我将从数据库中获取的数据转换为JSON并将其发送到客户端代码......
int start = 0;
int total = 0;
int total_pages = 0;
int intpage = new Integer(request.getParameter("page"));
int limit = new Integer(request.getParameter("rows"));
String sidx = request.getParameter("sidx");
String sord = request.getParameter("sord");
String strQuery = "";
String json = "";
boolean rc;
ResultSet rs = null;
if (sidx == "") {
sidx = "1";
}
/*
* -----------------------------------Conexión to MySql-------------------------------------------
*/
conexion conexiondb = new conexion();
conexiondb.Conectar();
/*
* -----------------------------------------------------------------------------------------------------------
*/
total = conexiondb.countRec("id", "processeddata_table", query);
if (total > 0) {
double d = Math.ceil((double) (total) / (double) (limit));
total_pages = (int) (d);
} else {
total_pages = 0;
}
if (intpage > total_pages) {
intpage = total_pages;
}
start = limit * intpage - limit;
if (start < 0) {
start = 0;
}
System.out.println(query);
strQuery = "SELECT *,date(calldate) as date,time(calldate) as time FROM processeddata_table where date(calldate) between '" + query + " ORDER BY " + sidx + " " + sord + " LIMIT " + start + " , " + limit;
System.out.println(strQuery);
rs = conexiondb.Consulta(strQuery);
total = conexiondb.countRec("id", "processeddata_table", query);
response.setContentType("text/x-json");
response.setCharacterEncoding("utf-8");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache, must-revalidate");
response.setHeader("Pragma", "no-cache");
json = "";
json = json + "{\n";
json = json + " \"page\":\"" + intpage + "\",\n";
json = json + "\"total\":" + total_pages + ",\n";
json = json + "\"records\":" + total + ",\n";
json = json + "\"rows\": [";
rc = false;
while (rs.next()) {
if (rc) {
json = json + ",";
}
json = json + "\n{";
json = json + "\"id\":\"" + rs.getInt("id") + "\",";
json = json + "\"cell\":[" + rs.getInt("id") + "";
json = json + ",\"" + rs.getString("date") + "\"";
json = json + ",\"" + rs.getString("time") + "\"";
json = json + ",\"" + rs.getString("source") + "\"";
json = json + ",\"" + rs.getString("destination") + "\"";
json = json + ",\"" + rs.getString("extension") + "\"";
json = json + ",\"" + rs.getString("trunk") + "\"";
json = json + ",\"" + rs.getString("duration") + "\"";
json = json + ",\"" + rs.getString("toc") + "\"";
json = json + ",\"" + rs.getString("callcost") + "\"";
json = json + ",\"" + rs.getString("Site") + "\"]";
json = json + "}";
rc = true;
}
json = json + "]\n";
json = json + "}";
out.print(json);
out.close();
请帮我解决这个问题..任何帮助将不胜感激。提前致谢..