UNPKG

jqwidgets-framework

Version:

jQWidgets is an advanced Angular, Vue, Blazor, React, Web Components, jquery, ASP .NET MVC, Custom Elements and HTML5 UI framework.

101 lines (100 loc) 6.03 kB
<!DOCTYPE html> <html ng-app="demoApp" lang="en"> <head> <title id='Description'>AngularJS DataTable with Validation. Double-Click on a Row to enter into edit mode. The editor of the "Ship Country" column passes the validation when minimum 5 characters are entered. "Freight" should be in the 0-1000 interval and "Shipped Date" should be in the 1990-2014 interval. "Order ID" is not editable.</title> <meta name="description" content="This is an example of AngularJS DataTable. DataTable Validation is demonstrated" /> <link rel="stylesheet" href="../../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../../scripts/angular.min.js"></script> <script type="text/javascript" src="../../../scripts/jquery-1.11.1.min.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdatatable.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxlistbox.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdropdownlist.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../../jqwidgets/jqxtooltip.js"></script> <script type="text/javascript" src="../../../scripts/demos.js"></script><script type="text/javascript" src="../../../jqwidgets/jqxangular.js"></script> <script type="text/javascript"> var demoApp = angular.module("demoApp", ["jqwidgets"]); demoApp.controller("demoController", function ($scope) { $scope.gridSettings = { width: 850, source: { dataFields: [ { name: 'OrderID', type: 'int' }, { name: 'Freight', type: 'float' }, { name: 'ShipName', type: 'string' }, { name: 'ShipAddress', type: 'string' }, { name: 'ShipCity', type: 'string' }, { name: 'ShipCountry', type: 'string' }, { name: 'ShippedDate', type: 'date' } ], root: "Orders", record: "Order", dataType: "xml", id: 'OrderID', url: "../../sampledata/orderdetails.xml", addRow: function (rowID, rowData, position, commit) { // synchronize with the server - send insert command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. // you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB. commit(true); }, updateRow: function (rowID, rowData, commit) { // synchronize with the server - send update command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. commit(true); }, deleteRow: function (rowID, commit) { // synchronize with the server - send delete command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. commit(true); } }, pageable: true, editable: true, altRows: true, ready: function() { // called when the Grid is loaded. }, pagerButtonsCount: 8, columns: [ { text: 'Order ID', editable: false, dataField: 'OrderID', width: 100 }, { text: 'Freight', dataField: 'Freight', cellsFormat: 'f2', cellsAlign: 'right', align: 'right', width: 100, validation: function (cell, value) { if (value > 1000 || value < 0) return { message: "Freight should be in the 0-1000 interval", result: false }; return true; } }, { text: 'Ship Country', dataField: 'ShipCountry', width: 150, validation: function (cell, value) { if (value.length < 5) return { message: "Ship Country should be minimum 5 characters", result: false }; return true; } }, { text: 'Shipped Date', dataField: 'ShippedDate', cellsAlign: 'right', align: 'right', cellsFormat: 'dd/MM/yyyy', validation: function (cell, value) { var date = new Date(value); if (date.getFullYear() > 2014 || date.getFullYear() < 1990) { return { message: "Shipped Date should be in the 1990 - 2014 interval", result: false }; } return true; } } ] }; }); </script> </head> <body ng-controller="demoController"> <jqx-data-table jqx-settings="gridSettings"></jqx-data-table> </body> </html>