서버에서 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})
그리고 여기에 데이터베이스에서 가져온 데이터를 JSON으로 변환하여 클라이언트 측 코드로 보내는 jsp 코드가 있습니다.
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();
이 문제를 해결하도록 도와주세요 .. 어떤 도움이라도 대단히 감사하겠습니다. 미리 감사드립니다 ..
그룹화를 수행하려면 다음 그리드 구성을 코드에 추가해야합니다.
grouping:true,
groupingView : {
groupField : ['column_name'],
groupSummary : [true],
groupColumnShow : [true],
groupText : ['<b>{0}</b>'],
groupCollapse : false,
groupOrder: ['asc']
}
이렇게하면 데이터 그룹화를 구성하는 데 도움이됩니다. 그룹화 및 요약 바닥 글 데이터에 대한 자세한 내용은 jQgrid 데모 를 확인하고 해당 참조 요약 바닥 글에서 그룹화를 확인하십시오. 이것이 도움이되는지 알려주세요.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다