Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. controller do
  2. def index
  3. redirect_to manage_admin_pay_records_path
  4. end
  5. end
  6.  
  7. collection_action :manage do
  8. end
  9.  
  10. collection_action :json do
  11. page = params[:page].to_i
  12. rows = params[:rows].to_i
  13. records = PayRecord.all.count
  14. total = (records.to_f / rows.to_f).ceil
  15. @pay_records = PayRecord.page(page).per(rows)
  16. result = {
  17. "total" => total,
  18. "page" => page,
  19. "records" => records,
  20. "rows" => @pay_records
  21. }
  22. render :json => result
  23. end
  24.  
  25. <table id="list2"></table> <div id="pager2"></div>
  26. <script>
  27. $("#list2").jqGrid({
  28. url : '/admin/pay_records/json',
  29. datatype : "json",
  30. colNames : [ 'id'],
  31. colModel : [
  32. {name : 'id', index : 'id',width : 5}
  33. ],
  34. rowNum : 10,
  35. autowidth : true,
  36. height : 'auto',
  37. pager : '#pager2',
  38. sortname : 'id',
  39. viewrecords : true,
  40. sortorder : "desc",
  41. caption : "Pay Records",
  42. emptyrecords : "Empty Records"
  43. });
  44.  
  45. $("#list2").jqGrid('navGrid',"#pager2",{ pdf : true, edit : false, add : false, del : false, search : true }, {}, {}, {}, { sopt : [ 'eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew' ],
  46. closeOnEscape : true,
  47. multipleSearch : true,
  48. closeAfterSearch : true
  49. });
  50. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement