JQuery easyUI + struts2 + hibernate + oracle
Implement Paging for admin users
Core code
Init. js
$ (Document). ready (function (){
// Obtain all a Elements
Var $ as =$ ("li> ");
// Obtain the element id = tabs
Var $ tt = $ ("# tt ");
// Register a click event
$ As. bind ("click", function (){
Var text = $ (this). text ();
Var url = this. href;
// Obtain the added text based on the obtained id = whether the tt panel contains a panel containing the text title
Var curtab = $ ("# tt"). tabs ("getTab", text );
Alert (curtab );
If (curtab ){
// JQuery object
Var iframe = $ (curtab. panel ('options'). content );
// Obtain the attribute value based on the attribute name
Var src1 = iframe. attr ("src ");
$ ("# Tt"). tabs ("update ",{
Tab: curtab,
Options :{
Content: createFrame (src1)
}
});
} Else {
$ ("# Tt"). tabs ('add ',{
Title: text,
Closable: true,
Content: createFrame (url), // create the panel content
Tools :[{
IconCls: 'icon-mini-refresh ',
Handler: function (){
Alert ('refresh ');
}
}]
});
}
Return false;
});
});
// Create a panel
Function createFrame (url ){
Var src = '<iframe scrolling = "auto" frameborder = "0" src = "' + url + '" style = "width: 100%; height: 100%; "> </iframe> ';
Return src;
}
Adminlist. js
$ (Document). ready (function (){
$ ('# Adminlist'). datagrid ({
Url: './csdn/AdminAction_query.action? Time = '+ new Date (). getTime (),
LoadMsg: "The data is being loaded ...... ",
PageNumber: 1, // The initial page number for initialization
PageSize: 10, // The data volume displayed on each page (test changes do not change)
PageList: [10, 15, 20], // The data size per page is optional
SortName: 'aid ', // defines the name of the arrangement
SortOrder: 'asc ', // defines the way asc is arranged
Striped: true, // determines whether to enable the color of the barrier.
FitColumns: true, // whether to automatically set the column width
SingleSelect: false,
IdField: 'id', // Id field
FrozenColumns :[[{
Field: 'ck ',
Checkbox: true
},{
Title: 'sequence number ',
Field: 'aid ',
Width: 50,
Sortable: true
}],
Columns :[[{
Field: 'aname ',
Title: 'username ',
Width: 100
},{
Field: 'apass ',
Title: 'Password ',
Width: 100,
Align: 'left ',
Editor :{
Type: 'text'
}
}],
Pagination: true,
Shownumbers: false,
Toolbar :[{
IconCls: "icon-add ",
Text: "add ",
Handler: function (){
$ ("# Adminlist"). dialog ("open ");
}
},{
IconCls: "icon-remove ",
Text: "delete ",
Handler: function (){
Var datas = $ ('# adminlist'). datagrid ('getselections ');
If (datas. length <= 0 ){
ShowMsg ("prompt", "No selected data, cannot be deleted! ");
Return;
}
$ (Datas). each (function (index ){
Var rowIndex = $ ('# adminlist'). datagrid ('getrowindex', this );
$ ('# Adminlist'). datagrid ('delterow', rowIndex );
Ids = this. aid;
});
$. Post ("./csdn/AdminAction_deleteById.action ",{
Id: ids
}, Function (){
ShowMsg ("successful", "deleted successfully! ");
$ ('# Adminlist'). datagrid ('reload ');
});
}
},{
IconCls: "icon-edit ",
Text: "modify ",
Handler: function (){
Alert ("modify ");
}
},{
IconCls: "icon-save ",
Text: "save ",
Handler: function (){
Alert ("save ");
}
}]
});
Var pagination = $ ('# adminlist'). datagrid ('getpager ');
// Set paging attributes
Pagination. pagination ({
BeforePageText: "th ",
AfterPageText: "pages {pages ",
DisplayMsg: "from article {from} to Article {to} total {total"
});
$ ("# Adminlist"). dialog ({
Title: "adding Administrators ",
Modal: true,
Width: 300,
Height: 350,
Closed: true,
OnBeforeOpen: function (){
$ ("# ParentType"). combotree ("reload ");
$ ("# Add"). form ("clear ");
}
});
$ ("# Add"). form ({
Url: '../csdn/addGoodsType. action ',
OnSubmit: function (){
If (! $ ("# Aname"). validatebox ("isValid") |! $ ("# Apass"). validatebox ("isValid ")){
Return false;
}
},
Success: function (data ){
$ ("# Adminlist"). dialog ("close ");
$ ('# Adminlist'). datagrid ("reload ");
}
});
$ ('# Adminlist'). datagrid ({
OnDblClickRow: function (rowIndex, rowData ){
// Alert (rowIndex + "------" + rowData. aname );
$ ('# Adminlist'). datagrid ("beginEdit", rowIndex );
}
});
});
Function showMsg (title, msg ){
$. Messager. show ({
Title: title,
ShowType: "slide ",
Msg: msg,
Timeout: 1000
});
}
Index. jsp
<% @ Page language = "java" import = "java. util. *" pageEncoding = "UTF-8" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + "://"
+ Request. getServerName () + ":" + request. getServerPort ()
+ Path + "/";
%>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Base href = "<% = basePath %>">
<Title> My JSP 'index. jsp 'starting page </title>
<Meta http-equiv = "pragma" content = "no-cache">
<Meta http-equiv = "cache-control" content = "no-cache">
<Meta http-equiv = "expires" content = "0">
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3">
<Meta http-equiv = "description" content = "This is my page">
<! --
<Link rel = "stylesheet" type = "text/css" href = "styles.css">
-->
<Link rel = "stylesheet" type = "text/css"
Href = "$ {pageContext. request. contextPath}/styles/easyui/themes/default/easyui.css">
<Link rel = "stylesheet" type = "text/css"
Href = "$ {pageContext. request. contextPath}/styles/easyui/themes/icon.css">
<Link rel = "stylesheet" type = "text/css"
Href = "$ {pageContext. request. contextPath}/styles/manager/init.css">
<Script type = "text/javascript"
Src = "$ {pageContext. request. contextPath}/scripts/jquery-1.8.0.min.js"> </script>
<Script type = "text/javascript"
Src = "$ {pageContext. request. contextPath}/scripts/jquery. easyui. min. js"> </script>
<Script type = "text/javascript"
Src = "$ {pageContext. request. contextPath}/scripts/manager/init. js"> </script>
</Head>
<Body>
<Div id = "box" class = "easyui-layout">
<! -- Start from north -->
<Div data-options = "region: 'North ', title: 'North title', split: true"
Style = "height: 100px;"> </div>
<! -- North End -->
<% -- <Div
Data-options = "region: 'east', iconCls: 'icon-reload', title: 'east', split: true"
Style = "width: 100px;"> </div>
-- %>
<! -- West -->
<Div data-options = "region: 'west', title: 'navigation menu ', split: true"
Style = "width: 200px;">
<Div id = "nav" class = "easyui-accordion"
Data-options = "fit: true, border: false"
Style = "padding-right: 5px; padding-left: 5px;">
<Div title = "administrator management" data-options = "iconCls: 'icon-save'">
<Ul>
<Li> <
Href = "$ {pageContext. request. contextPath}/backstage/admin/admin_list.jsp"> administrator list </a>
</Li>
</Ul>
</Div>
<Div title = "member management">
<Ul>
<Li> <a href = "#"> member list </a> </li>
</Ul>
</Div>
<Div title = "Product Category Management" data-options = "iconCls: 'icon-reload '"
Style = "padding: 10px;">
<Ul>
<Li> <a href = "$ {pageContext. request. contextPath}/backstage/goodstype_list.jsp"> product category list </a> </li>
</Ul>
</Div>
<Div title = "item management" data-options = "iconCls: 'icon-reload '"
Style = "padding: 10px;">
<Ul>
<Li> <a href = "#"> item list </a> </li>
</Ul>
</Div>
</Div>
</Div>
<! -- West End -->
<! -- Center start -->
<Div data-options = "region: 'center'" style = "">
<Div id = "tt" class = "easyui-tabs" data-options = "fit: true">
<Div title = "background operation interface" style = "padding: 20px;"> background operation interface description </div>
</Div>
</Div>
<! -- Center end -->
<! -- South -->
<Div data-options = "region: 'south', split: true"
Style = "height: 25px; padding: 5px; background: # D2E0F2;">
<Div align = "center"> copyright belongs to Hebei software Vocational and Technical College @ hesoft CSDN lezhi College, 2013-2020 </div>
</Div>
<! -- South End -->
</Div>
</Body>
</Html>