Navigation.xrw 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <?xml-stylesheet href="../../css/body.css" type="text/css" ?>
  3. <xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2002/01/xforms" xmlns:ev="http://www.w3.org/2001/xml-events">
  4. <xhtml:head>
  5. <xhtml:title>Untitle</xhtml:title>
  6. <model id="model1">
  7. <instance id="instance1">
  8. <root xmlns="">
  9. <navInfo>
  10. <PageNo/>
  11. </navInfo>
  12. </root>
  13. </instance>
  14. </model>
  15. <script type="javascript">
  16. <![CDATA[
  17. function JsGridClass(datagrid, nodeset) {
  18. var pageNo = 1;
  19. var pageCount = 0;
  20. this.setItem = function() {
  21. var count = Math.ceil(Number(model.getXPathValue("count(" + nodeset + ")")) / 20);
  22. if (count == 1) {
  23. grpPages.visible = false;
  24. return;
  25. }
  26. grpPages.visible = true;
  27. for (var i = count; i < pageCount; i++) {
  28. model.removenode(nodeset + "[last()]");
  29. }
  30. for (var i = pageCount + 1; i <= count; i++) {
  31. model.makeValue("/root/navInfo/item["+i+"]/PageNo", i);
  32. }
  33. pageCount = count;
  34. }
  35. this.firstPage = function() {
  36. pageNo = 1;
  37. this.setPage();
  38. }
  39. this.prevPage = function() {
  40. pageNo--;
  41. this.setPage();
  42. }
  43. this.nextPage = function() {
  44. pageNo++;
  45. this.setPage();
  46. }
  47. this.lastPage = function() {
  48. pageNo = pageCount;
  49. this.setPage();
  50. }
  51. this.setPage = function(page) {
  52. showProgressBar();
  53. if (typeof page == "number") pageNo = page;
  54. var startposition = (pageNo - 1) * 20;
  55. var endposition = pageNo * 20;
  56. // datagrid.nodeset = nodeset + "[position()>" + startposition + " and position()<=" + endposition + "]";
  57. datagrid.nodeset = nodeset + "[ROWNUM>" + startposition + " and ROWNUM<=" + endposition + "]";
  58. datagrid.setSeqRowHeader(parseInt(startposition + 1));
  59. if (pageNo == 1) {
  60. btnFirst.disabled = true;
  61. btnPrev.disabled = true;
  62. btnNext.disabled = false;
  63. btnLast.disabled = false;
  64. } else if (pageNo == pageCount) {
  65. btnFirst.disabled = false;
  66. btnPrev.disabled = false;
  67. btnNext.disabled = true;
  68. btnLast.disabled = true;
  69. } else {
  70. btnFirst.disabled = false;
  71. btnPrev.disabled = false;
  72. btnNext.disabled = false;
  73. btnLast.disabled = false;
  74. }
  75. model.makeValue("/root/navInfo/PageNo", pageNo);
  76. try {
  77. pageInit();
  78. } catch (e) {}
  79. removeProgressBar();
  80. }
  81. this.isLastPage = function() {
  82. return pageNo == pageCount;
  83. }
  84. }
  85. ]]>
  86. </script>
  87. </xhtml:head>
  88. <xhtml:body pagewidth="460" pageheight="30">
  89. <group id="grpPages" style="left:0px; top:0px; width:390px; height:30px; ">
  90. <button id="btnFirst" disabled="true" style="left:5px; top:5px; width:85px; height:20px; background-image:../../images/cal_pre_y.gif; ">
  91. <caption>第一页</caption>
  92. <script type="javascript" ev:event="onclick">
  93. <![CDATA[
  94. try {
  95. JsGridObject.firstPage();
  96. } catch(e) {}
  97. ]]>
  98. </script>
  99. </button>
  100. <caption id="caption1" style="left:305px; top:5px; width:15px; height:20px; ">第</caption>
  101. <caption id="caption2" style="left:375px; top:5px; width:15px; height:20px; ">页</caption>
  102. <select1 id="combo1" ref="/root/navInfo/PageNo" appearance="minimal" style="left:320px; top:5px; width:50px; height:20px; ">
  103. <choices>
  104. <itemset nodeset="/root/navInfo/item">
  105. <label ref="PageNo"/>
  106. <value ref="PageNo"/>
  107. </itemset>
  108. </choices>
  109. <script type="javascript" ev:event="xforms-value-changed">
  110. <![CDATA[
  111. try {
  112. JsGridObject.setPage(Number(event.pTarget.value));
  113. } catch(e) {}
  114. ]]>
  115. </script>
  116. </select1>
  117. <button id="btnPrev" disabled="true" style="left:80px; top:5px; width:85px; height:20px; background-image:../../images/cal_pre_m.gif; ">
  118. <caption>上一页</caption>
  119. <script type="javascript" ev:event="onclick">
  120. <![CDATA[
  121. try {
  122. JsGridObject.prevPage();
  123. } catch(e) {}
  124. ]]>
  125. </script>
  126. </button>
  127. <button id="btnNext" style="left:155px; top:5px; width:85px; height:20px; background-image:../../images/cal_next_m.gif; ">
  128. <caption>下一页</caption>
  129. <script type="javascript" ev:event="onclick">
  130. <![CDATA[
  131. try {
  132. JsGridObject.nextPage();
  133. } catch(e) {}
  134. ]]>
  135. </script>
  136. </button>
  137. <button id="btnLast" style="left:230px; top:5px; width:85px; height:20px; background-image:../../images/cal_next_Y.gif; ">
  138. <caption>最末页</caption>
  139. <script type="javascript" ev:event="onclick">
  140. <![CDATA[
  141. try {
  142. JsGridObject.lastPage();
  143. } catch(e) {}
  144. ]]>
  145. </script>
  146. </button>
  147. </group>
  148. </xhtml:body>
  149. </xhtml:html>