`

Dhtmlxgrid分页代码解析

 
阅读更多

//------------------------Dhtmlxgrid真分页代码解析---------------------------//

//
//
//
//
//
//---------分组代码-----------//
//页面上可以增加数据分组
//其中参数5是根据第五列的内容进行分组
grid.groupBy(5);
//---------分组代码-----------//


//---------排序代码-----------//
//通过onBeforeSorting事件,对用户点击排序的时间进行监听
//增加排序监听器
//ind是用户选择排序的列
grid.attachEvent("onBeforeSorting", function(ind){
customColumnSort(grid,ind);
});
//排序
function customColumnSort(grid,ind){
//获取当前grid的排序状态
var a_state = grid.getSortingState();
//添加window全局的属性
   window.s_col = ind;//排序的列
//正则表达式
//如果当前列的状态的排序为升序,则改为降序
   window.a_direction = ((a_state[1] == "des") ? "asc": "des");
//重新加载页面
    reloadGrid(grid);
    return false;
}
//---------排序代码-----------//

//---------重新加载grid代码-----------//
//重新加载数据
function reloadGrid(grid){
    grid.clearAndLoad("<计算的值>Agent_GetView?OpenAgent" + "&orderBy=" + window.s_col + "&direction=" + window.a_direction);
//改变升序、降序的图标显示
    if(window.a_direction){
     grid.setSortImgState(true, window.s_col, window.a_direction);
}
}
//---------重新加载grid代码-----------//
//---------翻页后进行分组-----------//
//增加翻页后分组
grid.attachEvent("onPageChanged", function(ind,fInd,lInd){
//数据加载后分组
grid.groupBy(5);
});
//---------翻页后进行分组-----------//



//
//
//
//
//



//---------首先获取前台传过来的参数-----------//
REM 对post过来的数据进行解码
queryAr = Evaluate(|@URLDecode("Domino";Query_String)|,doc)
strPost = queryAr(0)


REM 设置起始位置数
If GetParameter("posStart",strPost) <> "" Then
posStart = GetParameter("posStart",strPost)
Else
//默认从第0条数据开始加载
posStart = 0
End If
REM 设置一页展示的条数
If GetParameter("count",strPost) <> "" Then
count = GetParameter("count",strPost)
Else
REM 默认第一次加载50条
count = 50
End If

//根据选择不同的列,对orderBy、orderByFormula进行赋值
REM 设置取得排序列
If GetParameter("orderBy",strPost) <> "" Then
REM 按标题排序
If GetParameter("orderBy",strPost) = "0" Then
orderBy = "0"
orderByFormula = "REQUESTNUMBER + CallShortName + subject"
End If
REM 按当前处理人
If GetParameter("orderBy",strPost) = "1" Then
If viewtype = "recyclebin" Then
orderBy = "1"
orderByFormula = "sys_delmanshortname"
Else
orderBy = "1"
orderByFormula = "Cur_approver"
End If
End If
REM 按当前状态
If GetParameter("orderBy",strPost) = "2" Then
orderBy = "2"
orderByFormula = "Status"
End If
REM 按起草时间
If GetParameter("orderBy",strPost) = "3" Then
orderBy = "3"
orderByFormula = "@Created"
End If
Else
REM 默认是按时间排序
orderBy = "3"
orderByFormula = "@Created"
End If

REM 排序列方向[升序与降序]
If GetParameter("direction",strPost) <> "" Then
direction = Ucase(GetParameter("direction",strPost))
Else
REM 默认是按时间排序,递减
direction = "DES"
End If
//---------首先获取前台传过来的参数-----------//


//最后就是根据不同的条件进行对数据库不同的查询
//如果是domino数据库的,可以创建自定义视图,然后再取值
//如果是关系型数据库,可以创建不同的SQL语句进行查询
//萝卜青菜各有所爱。
//希望以上的代码能帮到您们。
//------------------------Dhtmlxgrid真分页代码解析--------------------------//

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics