Advertisement
Guest User

Untitled

a guest
Aug 29th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 8.00 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <title id='Description'>In order to enter in edit mode, select a grid cell and start typing, "Click" or press the "F2" key. You
  6.     can also navigate through the cells using the keyboard arrows or with the "Tab" and "Shift + Tab" key combinations. To cancel the cell editing, press the "Esc" key. To save
  7.     the changes press the "Enter" key or select another Grid cell. Pressing the 'Space' key when a checkbox cell is selected will toggle the check state.</title>
  8.     <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
  9.     <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
  10.     <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
  11.     <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
  12.     <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
  13.     <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
  14.     <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
  15.     <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
  16.     <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>  
  17.     <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
  18.     <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
  19.     <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
  20.     <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
  21.     <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script>
  22.     <script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script>
  23.     <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script>
  24.     <script type="text/javascript" src="../../jqwidgets/jqxgrid.grouping.js"></script>
  25.     <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script>
  26.     <script type="text/javascript" src="../../scripts/gettheme.js"></script>
  27.     <script type="text/javascript" src="generatedata.js"></script>
  28.     <script type="text/javascript">
  29.         $(document).ready(function () {
  30.             var theme = getDemoTheme();
  31.  
  32.             // prepare the data
  33.             var data = generatedata(200);
  34.  
  35. //            var source =
  36. //            {
  37. //                localdata: data,
  38. //                datatype: "array",
  39. //                updaterow: function (rowid, rowdata, commit) {
  40. //                    // synchronize with the server - send update command
  41. //                    // call commit with parameter true if the synchronization with the server is successful
  42. //                    // and with parameter false if the synchronization failder.
  43. //                    commit(true);
  44. //                },
  45. //                datafields:
  46. //                [
  47. //                    { name: 'firstname', type: 'string' },
  48. //                    { name: 'lastname', type: 'string' },
  49. //                    { name: 'productname', type: 'string' },
  50. //                    { name: 'available', type: 'bool' },
  51. //                    { name: 'quantity', type: 'number' },
  52. //                    { name: 'price', type: 'number' },
  53. //                    { name: 'date', type: 'date' }
  54. //                ]
  55. //            };
  56. //
  57. //            var dataAdapter = new $.jqx.dataAdapter(source);
  58.  
  59.             var url = "../sampledata/customers.xml";
  60.             var source =
  61.             {
  62.                 datatype: "xml",
  63.                 datafields: [
  64.                     { name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName' },
  65.                     { name: 'ContactName', map: 'm\\:properties>d\\:ContactName' },
  66.                     { name: 'ContactTitle', map: 'm\\:properties>d\\:ContactTitle' },
  67.                     { name: 'City', map: 'm\\:properties>d\\:City' },
  68.                     { name: 'PostalCode', map: 'm\\:properties>d\\:PostalCode' },
  69.                     { name: 'Country', map: 'm\\:properties>d\\:Country' }
  70.                 ],
  71.                 root: "entry",
  72.                 record: "content",
  73.                 id: 'm\\:properties>d\\:CustomerID',
  74.                 url: url
  75.             };
  76.             var dataAdapter = new $.jqx.dataAdapter(source);
  77.  
  78.             // initialize jqxGrid
  79.             $("#jqxgrid").jqxGrid(
  80.             {
  81.                 width: 685,
  82.                 source: dataAdapter,
  83.                 editable: true,
  84.                 theme: theme,
  85.                 groupable:true,
  86.                 groups: ["CompanyName"],
  87.                 selectionmode: 'multiplecellsadvanced',
  88.                 columns: [
  89.                   { text: 'First Name', columntype: 'textbox', datafield: 'CompanyName', width: 80 },
  90.                   { text: 'Last Name', datafield: 'ContactName', columntype: 'textbox', width: 80 },
  91.                   { text: 'Product', columntype: 'dropdownlist', datafield: 'ContactTitle', width: 195 },
  92.                   { text: 'Available', datafield: 'available', columntype: 'checkbox', width: 67 },
  93.                   {
  94.                       text: 'Ship Date', datafield: 'date', columntype: 'datetimeinput', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'd',
  95.                   validation: function (cell, value) {
  96.                           if (value == "")
  97.                              return true;
  98.  
  99.                           var year = value.getFullYear();
  100.                           if (year >= 2014) {
  101.                               return { result: false, message: "Ship Date should be before 1/1/2014" };
  102.                           }
  103.                           return true;
  104.                       }
  105.                   },
  106.                   {
  107.                       text: 'Quantity', datafield: 'quantity', width: 70, align: 'right', cellsalign: 'right', columntype: 'numberinput',
  108.                       validation: function (cell, value) {
  109.                           if (value < 0 || value > 150) {
  110.                               return { result: false, message: "Quantity should be in the 0-150 interval" };
  111.                           }
  112.                           return true;
  113.                       },
  114.                       createeditor: function (row, cellvalue, editor) {
  115.                           editor.jqxNumberInput({ decimalDigits: 0, digits: 3 });
  116.                       }
  117.                   },
  118.                   { text: 'Price', datafield: 'price', align: 'right', cellsalign: 'right', cellsformat: 'c2', columntype: 'numberinput',
  119.                       validation: function (cell, value) {
  120.                           if (value < 0 || value > 15) {
  121.                               return { result: false, message: "Price should be in the 0-15 interval" };
  122.                           }
  123.                           return true;
  124.                       },
  125.                       createeditor: function (row, cellvalue, editor) {
  126.                           editor.jqxNumberInput({ digits: 3 });
  127.                       }
  128.  
  129.                   }
  130.                 ]
  131.             });
  132.  
  133.             // events
  134.             $("#jqxgrid").on('cellbeginedit', function (event) {
  135.                 var args = event.args;
  136.                 $("#cellbegineditevent").text("Event Type: cellbeginedit, Column: " + args.datafield + ", Row: " + (1 + args.rowindex) + ", Value: " + args.value);
  137.             });
  138.  
  139.             $("#jqxgrid").on('cellendedit', function (event) {
  140.                 var args = event.args;
  141.                 $("#cellendeditevent").text("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (1 + args.rowindex) + ", Value: " + args.value);
  142.             });
  143.         });
  144.     </script>
  145. </head>
  146. <body class='default'>
  147.     <div id='jqxWidget'>
  148.         <div id="jqxgrid"></div>
  149.         <div style="font-size: 12px; font-family: Verdana, Geneva, 'DejaVu Sans', sans-serif; margin-top: 30px;">
  150.             <div id="cellbegineditevent"></div>
  151.             <div style="margin-top: 10px;" id="cellendeditevent"></div>
  152.        </div>
  153.     </div>
  154. </body>
  155. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement