Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>http://stackoverflow.com/q/8900040/315935</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/redmond/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/css/ui.jqgrid.css" />
- <link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/plugin/ui.multiselect.css" />
- <style type="text/css">
- html, body { font-size: 75%; }
- </style>
- <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/jquery-ui.min.js"></script>
- <script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/plugin/ui.multiselect.js"></script>
- <script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/js/i18n/grid.locale-en.js"></script>
- <script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.3.1/js/jquery.jqGrid.src.js"></script>
- <script type="text/javascript">
- //<![CDATA[
- /*global $ */
- /*jslint devel: true, browser: true */
- $(document).ready(function () {
- 'use strict';
- var mydata = [
- { id: "1", invdate: "2007-10-01", name: "test", note: "note", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
- { id: "2", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
- { id: "3", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
- { id: "4", invdate: "2007-10-04", name: "test4", note: "note4", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
- { id: "5", invdate: "2007-10-31", name: "test5", note: "note5", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
- { id: "6", invdate: "2007-09-06", name: "test6", note: "note6", amount: "400.00", tax: "30.00", closed: false, ship_via: "FE", total: "430.00" },
- { id: "7", invdate: "2007-10-04", name: "test7", note: "note7", amount: "200.00", tax: "10.00", closed: true, ship_via: "TN", total: "210.00" },
- { id: "8", invdate: "2007-10-03", name: "test8", note: "note8", amount: "300.00", tax: "20.00", closed: false, ship_via: "FE", total: "320.00" },
- { id: "9", invdate: "2007-09-01", name: "test9", note: "note9", amount: "400.00", tax: "30.00", closed: false, ship_via: "TN", total: "430.00" },
- { id: "10", invdate: "2007-09-08", name: "test10", note: "note10", amount: "500.00", tax: "30.00", closed: true, ship_via: "TN", total: "530.00" },
- { id: "11", invdate: "2007-09-08", name: "test11", note: "note11", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" },
- { id: "12", invdate: "2007-09-10", name: "test12", note: "note12", amount: "500.00", tax: "30.00", closed: false, ship_via: "FE", total: "530.00" }
- ],
- $grid = $("#list"),
- initDateEdit = function (elem) {
- setTimeout(function () {
- $(elem).datepicker({
- dateFormat: 'dd-M-yy',
- autoSize: true,
- changeYear: true,
- changeMonth: true,
- showButtonPanel: true,
- showWeek: true
- });
- }, 100);
- },
- initDateSearch = function (elem) {
- setTimeout(function () {
- $(elem).datepicker({
- dateFormat: 'dd-M-yy',
- autoSize: true,
- changeYear: true,
- changeMonth: true,
- showWeek: true,
- showButtonPanel: true
- });
- }, 100);
- },
- numberTemplate = {formatter: 'number', align: 'right', sorttype: 'number', editable: true,
- searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn', 'in', 'ni'] }};
- $grid.jqGrid({
- datatype: 'local',
- data: mydata,
- colNames: [/*'Inv No', */'Client', 'Date', 'Amount', 'Tax', 'Total', 'Closed', 'Shipped via', 'Notes'],
- colModel: [
- //{ name: 'id', index: 'id', width: 70, align: 'center', sorttype: 'int', searchoptions: { sopt: ['eq', 'ne']} },
- { name: 'name', index: 'name', editable: true, width: 70, editrules: { required: true},
- editoptions: { dataInit: function (elem) { $(elem).addClass('ui-state-highlight'); }}},
- { name: 'invdate', index: 'invdate', width: 80, align: 'center', sorttype: 'date',
- formatter: 'date', formatoptions: { newformat: 'd-M-Y' }, editable: true, datefmt: 'd-M-Y',
- editoptions: { dataInit: initDateEdit },
- searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge'], dataInit: initDateSearch } },
- { name: 'amount', index: 'amount', width: 80, template: numberTemplate },
- { name: 'tax', index: 'tax', width: 55, template: numberTemplate,
- editoptions: { dataInit: function (elem) { $(elem).addClass('ui-state-error'); }} },
- { name: 'total', index: 'total', width: 65, template: numberTemplate },
- {name: 'closed', index: 'closed', width: 75, align: 'center', editable: true, formatter: 'checkbox',
- edittype: 'checkbox', editoptions: {value: 'Yes:No', defaultValue: 'Yes'},
- stype: 'select', searchoptions: { sopt: ['eq', 'ne'], value: ':Any;true:Yes;false:No' } },
- {name: 'ship_via', index: 'ship_via', width: 105, align: 'center', editable: true, formatter: 'select',
- edittype: 'select', editoptions: { value: 'FE:FedEx;TN:TNT;IN:Intim', defaultValue: 'IN' },
- stype: 'select', searchoptions: { sopt: ['eq', 'ne'], value: ':Any;FE:FedEx;TN:TNT;IN:IN' } },
- { name: 'note', index: 'note', width: 60, sortable: false, editable: true, edittype: 'textarea' }
- ],
- rowNum: 10,
- rowList: [5, 10, 20],
- pager: '#pager',
- gridview: true,
- rownumbers: true,
- autoencode: true,
- ignoreCase: true,
- sortname: 'invdate',
- viewrecords: true,
- sortorder: 'desc',
- height: '100%',
- caption: 'Demonstrate how to use the columnChooser'
- });
- $grid.jqGrid('navGrid', '#pager', {refreshstate: 'current', add: false, edit: false, del: false});
- $.extend(true, $.ui.multiselect, {
- locale: {
- addAll: 'Make all visible',
- removeAll: 'Hidde All',
- itemsCount: 'Avlialble Columns'
- }
- });
- //$.extend(true, $.jgrid.col, {
- // width: 500,
- // msel_opts: {dividerLocation: 0.5}
- //});
- $grid.jqGrid('navButtonAdd', '#pager', {
- caption: "",
- buttonicon: "ui-icon-calculator",
- title: "Choose columns",
- onClickButton: function () {
- $(this).jqGrid('columnChooser',
- {width: 550, msel_opts: {dividerLocation: 0.5}});
- //$(this).jqGrid('columnChooser');
- $("#colchooser_" + $.jgrid.jqID(this.id) + ' div.available>div.actions')
- .prepend('<label style="float:left;position:relative;margin-left:0.6em;top:0.6em">Search:</label>');
- }
- });
- });
- //]]>
- </script>
- </head>
- <body>
- <table id="list"><tr><td/></tr></table>
- <div id="pager"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement