Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- controller do
- def index
- redirect_to manage_admin_pay_records_path
- end
- end
- collection_action :manage do
- end
- collection_action :json do
- page = params[:page].to_i
- rows = params[:rows].to_i
- records = PayRecord.all.count
- total = (records.to_f / rows.to_f).ceil
- @pay_records = PayRecord.page(page).per(rows)
- result = {
- "total" => total,
- "page" => page,
- "records" => records,
- "rows" => @pay_records
- }
- render :json => result
- end
- <table id="list2"></table> <div id="pager2"></div>
- <script>
- $("#list2").jqGrid({
- url : '/admin/pay_records/json',
- datatype : "json",
- colNames : [ 'id'],
- colModel : [
- {name : 'id', index : 'id',width : 5}
- ],
- rowNum : 10,
- autowidth : true,
- height : 'auto',
- pager : '#pager2',
- sortname : 'id',
- viewrecords : true,
- sortorder : "desc",
- caption : "Pay Records",
- emptyrecords : "Empty Records"
- });
- $("#list2").jqGrid('navGrid',"#pager2",{ pdf : true, edit : false, add : false, del : false, search : true }, {}, {}, {}, { sopt : [ 'eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew' ],
- closeOnEscape : true,
- multipleSearch : true,
- closeAfterSearch : true
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement