Fanruan big data custom paging

The first step is to build the query

1. Custom query statement: ${f} is the start page, ${p} is the number of pages, and the initial value is as shown in the figure

select * from table limit ${f},${p}

Set the initial value of p, or you can hard-code the parameters in the above figure, set the initial page as the page, and the default is 1 (the value of page). 

 Step 2: Custom button 7 buttons:

Set the template web properties for filling in or paging preview, and set it as the template customization:

Then design the loading end event

var toolbar = contentPane.toolbar;

var items = toolbar.options.items;

var customButton=items[2];//JQUERY取我们的工具栏上的按钮.items[2]代表的是第三个,也就是那个显示成文本框按钮。
//修正这个按钮的属性,让它变成文本类型,居中,鼠标放上次图标是编辑状态。
var cellValue = contentPane.curLGP.getCellValue("D1");//获取D1单元格的值就是page,也就是当前页。
customButton.setText(cellValue);


var total=contentPane.curLGP.getCellValue("C1");

if (total>parseInt(total)){
total=parseInt(total)+1;
}
contentPane.toolbar.options.items[4].setText(total);
//把总页数显示在第5个控件上,因为这个数值可能是小数,所以判断下要不要加一处理。
contentPane.toolbar.options.items[3].setText(contentPane.curLGP.getCellValue("E1"));

These values ​​come from the first row of the cell: the value of the cell of A1, B1, C1, D1, D1, where C1 is the total number of rows queried

=$page-1    =$page+1    ds2.G(zs)    =$page    ="/" 

Define the js of the first button home page

window.location.href="${servletURL}?viewlet=报表.cpt&op=write&page=1";//链接到fenye.cpt,page 参数=1,代表第一页。

second button previous page

var page= $("tr[tridx=0]","div.content-container").children().eq(0).html();  //取第一行第一个单元格内容。

if(page==0)

{

this.setEnable(false);

alert("页面超出指定的范围");

}

else

window.location.href="${servletURL}?viewlet=报表.cpt&op=write&page="+page//如果没有小于1就正常跳转,否则显示页面超过指定的范围,这个控件设置不可以使用。

third button current page

var toolbar = contentPane.toolbar;

        var items = toolbar.options.items;

        var customButton=items[2];

        var inner = customButton.$table;

        var btnWrapper = $("em", inner);

var $input = $("input", btnWrapper);

//取这个控件

$input.blur(function(){

  var toolbar = contentPane.toolbar;

        var items = toolbar.options.items;

        var customButton=items[2];

        var inner = customButton.$table;

        var btnWrapper = $("em", inner);

var $input = $("input", btnWrapper);

var page=$input.val();

var total=$("tr[tridx=0]","div.content-container").children().eq(2).html(); 

if (total>parseInt(total)){total=parseInt(total)+1;

}

if(parseInt(page) > parseInt(total) || parseInt(page) < parseInt(1) )

{

alert("你输出的页数不再指定范围内");

}

else

window.location.href="${servletURL}?viewlet=报表.cpt&op=write&page="+page

});

 The fourth button page break: the total number of pages of the fifth button, no js event

The 6th button next page

var page= $("tr[tridx=0]","div.content-container").children().eq(1).html();  
var total=$("tr[tridx=0]","div.content-container").children().eq(2).html(); 
//JQURUY取下一页和总页数
      if (total>parseInt(total)){total=parseInt(total)+1;
     }
//判断总页数是不是整数,不是加一
      if(parseInt(page) > parseInt(total))
  {
this.setEnable(false);
alert("页数超出指定范围内");
}
else
window.location.href="${servletURL}?viewlet=报表.cpt&op=write&page="+page
//如果下一页在这个范围就跳转到那里

7th button end page

var total=$("tr[tridx=0]","div.content-container").children().eq(2).html();  
//取总页数。
if (total>parseInt(total)){total=parseInt(total)+1;
}
window.location.href="${servletURL}?viewlet=报表.cpt&op=write&page="+total
//判断总页数是不是整数,不是加一,并跳转到最后一页。

 The third part shows the result:

 

 

Guess you like

Origin blog.csdn.net/qq_26408545/article/details/102932292