我想在点击标题时保持页面位置。但是,如果我在第 5 页并单击页眉,则页面位置更改为 1 页。(排序是完美的)如果我点击第 5 页的标题,我想保持我的页面位置,仍然保持位置 5 页面并且排序是完美的。
我认为这不足以解释我的情况。所以我发布我的开发环境
我正在使用struts2和mysql。这是我的javascript。
function fnGridInitSW(){
swgrid = new dhtmlXGridObject('swGridBox');
swgrid.setImagePath("../../../common/img/dhtmlx/grid/");
swgrid.setHeader("SoftWareName, company, version, Install_date");
swgrid.setColumnIds(
"COL_1"
+",COL_2"
+",COL_3"
+",COL_4"
);
swgrid.setInitWidthsP("25,25,25,*");
swgrid.setColTypes("ro,ro,ro,ro");
swgrid.setColSorting("str,str,str,str");
swgrid.attachEvent("onXLS", function(){
$("#swnotfound").hide();
$("#swgridLoading").show();
});
swgrid.attachEvent("onXLE", function(){
$("#swgridLoading").hide();
swgrid.changePage(chPg);
$("#swnotfound").hide();
});
swgrid.init();
swgrid.attachEvent("onBeforePageChanged",function(ind,count){
chPg = count;
if (!swgrid.getRowsNum()){
return false;
};
return true;
});
var mygrid_state = swgrid.getSortingState();
popFnSearch(swgrid.getColumnId(mygrid_state[0]), mygrid_state[1]);
// Custom Sorting
swgrid.attachEvent("onBeforeSorting",function(ind, type, direction) {
popFnSearch(swgrid.getColumnId(ind), direction);
var sInd;
var mygrid_state = swgrid.getSortingState();
if( typeof(mygrid_state[0]) == "undefined" ){
sInd = ind;
}
direction = (mygrid_state[1] == "des") ? "asc": "des";
swgrid.setSortImgState(true,sInd,direction);
return true;
});
}
function popFnSearch(sortC, sortD) {
if( typeof(sortC) == "undefined" ) sortC = swgrid.getColumnId(3);
if( typeof(sortD) == "undefined" ) sortD = "desc";
var params = "/url/Info.do?"&sortC="+sortC+"&sortD="+sortD+"&pageCnt=5";
swgrid.clearAndLoad(params);
}
这是我的网格 xml。
<%@ page language="java" contentType="text/xml; charset=UTF-8" pageEncoding="UTF-8"%>
<rows total_count='<s:property value="%{totalCnt}" />' pos='<s:property value="%{posStart}" />'>
<s:if test="softwareList.size > 0">
<s:iterator value="%{softwareList}" status="index">
<row id="'index<s:property value='%{SW_SEQNO}'/>'">
<cell><s:property value="%{SW_NM}" /></cell>
<cell><s:property value="%{SW_COMPANY}" /></cell>
<cell><s:property value="%{SW_VER}" /></cell>
<cell class="last"><s:property value="%{INST_DT}" /></cell>
</row>
</s:iterator>
</s:if>
</rows>
这是我的查询
//get total count from softwarelist
<select id="getSoftwareInfoTotCnt" resultClass="Integer" parameterClass = "d">
SELECT IFNULL(COUNT(*), 0)
FROM T_PC_SW_LIST sl
JOIN T_SOFTWARE so ON sl.SW_SEQNO = so.SW_SEQNO
</select>
//get real data from softwarelist
<select id="getSoftwareInfo" resultClass="c" parameterClass = "d">
SELECT
sl.SW_SEQNO
, sl.ASST_SEQNO
, so.SW_NM
, so.SW_COMPANY
, so.SW_VER
, DATE_FORMAT(sl.INST_DT, '%Y-%m-%d') AS INST_DT
FROM T_PC_SW_LIST sl
JOIN T_SOFTWARE so ON sl.SW_SEQNO = so.SW_SEQNO
ORDER BY $sortC$ $sortD$
LIMIT #posStart# , #count#
</select>
如果有人有解决方案请帮助我..