1. Code snippets related to pagination in view files
1 <formID= "Pagerform"Method= "POST"Action= "w_list.html">2 <inputtype= "hidden"name= "Pagenum"value= "1" />3 <inputtype= "hidden"name= "Numperpage"value= "<%= model.numperpage%>" />4 <inputtype= "hidden"name= "OrderField"value= "<%= param.orderfield%>" />5 <inputtype= "hidden"name= "Orderdirection"value= "<%= param.orderdirection%>" />6 </form>
1 <Divclass= "Panelbar" >2 <Divclass= "pages">3 <span>Show</span>4 <Selectname= "Numperpage"onchange= "Navtabpagebreak ({numPerPage:this.value})">5 <optionvalue= " the">20</option>6 <optionvalue= " the">50</option>7 <optionvalue= "+">100</option>8 <optionvalue= "$">200</option>9 </Select>Ten <span>Article, total 200 article</span> One </Div> A - <Divclass= "pagination"TargetType= "Navtab"TotalCount= "$"Numperpage= " the"Pagenumshown= "Ten"currentpage= "2"></Div> - the </Div> - - </Div>
The page looks like this:
Paging or sorting actions are called to the two key scripting methods in Dwz.ajax.js:
1 /**2 * handling pagination and sorting in Navtab3 * Targettype:navtab or dialog4 * Rel: Can be selected to refresh div ID number locally5 * data:pagerform parameter {pagenum: "n", Numperpage: "N", OrderField: "xxx", Orderdirection: "}6 * Callback: Load complete callback function7 */8 9 functiondwzpagebreak (options) {Ten varOP = $.extend ({targetType: "Navtab", rel: "", Data:{pagenum: "", Numperpage: "", OrderField: "", Orderdirection: ""}, CallbackNULL}, Options);
The parameter rel comes from an optional property of the second code 13 line above, which specifies the object that the paging action works when there are multiple forms within a page
One var$parent = Op.targettype = = "Dialog"?$.pdialog.getcurrent (): Navtab.getcurrentpanel ();
The $parent object obtained is a form form containing the id= "Pagerform" A - if(Op.rel) { - var$box = $parent. Find ("#" +Op.rel); the varform =_getpagerform ($box, op.data); - if(form) { - $box. Ajaxurl ({ -Type: "POST", url:$ (Form). attr ("action"), Data: $ (Form). Serializearray (), Callback:function(){ +$box. Find ("[Layouth]"). Layouth (); - } + }); A } at}Else { - varform =_getpagerform ($parent, op.data); - varparams =$ (form). Serializearray (); - - if(Op.targettype = = "Dialog") { - if(form) $.pdialog.reload (form). attr ("Action"), {data:params, callback:op.callback}); in}Else { - if(form) navtab.reload (form). attr ("Action"), {data:params, callback:op.callback}); to } + } -}
1 /**2 * 3 * @param {Object} args {pagenum: "", Numperpage: "", OrderField: "", Orderdirection: "}4 * @param String formId page form selector, the default value of non-mandatory is "pagerform"5 */6 function_getpagerform ($parent, args) {7 varForm = $ ("#pagerForm", $parent). Get (0);8 9 if(form) {Ten if(args["Pagenum"]) Form[dwz.pageinfo.pagenum].value = args["Pagenum"]; One if(args["Numperpage"]) Form[dwz.pageinfo.numperpage].value = args["Numperpage"]; A if(args["OrderField"]) Form[dwz.pageinfo.orderfield].value = args["OrderField"]; - if(args["Orderdirection"] && form[dwz.pageinfo.orderdirection]) Form[dwz.pageinfo.orderdirection].value = args["Orderdirection"]; - } the - returnform; -}
This time in the work, the main reason for paging failure is that there are not a few related hidden form elements in the paging sequence placed in the id= "Pagerform" , resulting in the first script method does not get the correct Jquery object $parent , the value of the form variable that is obtained when passed to the second method is undefined
DWZ pagination, sorting failure summary