Your search did not match any results.
Data Grid

Data Validation

Documentation

The DataGrid widget is able to validate data input within grid cells using predefined or custom validation rules. In this example, a validation rule is assigned to each column using its validationRules option. These rules do not allow an end user to enter invalid data into grid cells.

Copy to CodeSandBox
Apply
Reset
<template> <div> <dx-data-grid :data-source="dataSource" :show-borders="true" :column-auto-width="true" key-expr="ID" > <dx-editing :allow-updating="true" :allow-adding="true" mode="batch" /> <dx-paging :enabled="false"/> <dx-column data-field="FirstName"> <dx-required-rule/> </dx-column> <dx-column data-field="LastName"> <dx-required-rule/> </dx-column> <dx-column data-field="Position"> <dx-required-rule/> </dx-column> <dx-column data-field="Phone"> <dx-required-rule/> <dx-pattern-rule :pattern="pattern" message="Your phone must have &quot;(555) 555-5555&quot; format!" /> </dx-column> <dx-column data-field="Email"> <dx-required-rule/> <dx-email-rule/> </dx-column> </dx-data-grid> </div> </template> <script> import { DxDataGrid, DxColumn, DxPaging, DxEditing, DxRequiredRule, DxEmailRule, DxPatternRule } from 'devextreme-vue/data-grid'; import { employees } from './data.js'; export default { components: { DxDataGrid, DxColumn, DxPaging, DxEditing, DxRequiredRule, DxEmailRule, DxPatternRule }, data() { return { dataSource: employees, pattern: /^\(\d{3}\) \d{3}-\d{4}$/i }; } }; </script>
import Vue from 'vue'; import App from './App.vue'; new Vue({ el: '#app', components: { App }, template: '<App/>' });
<!DOCTYPE html> <html> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> </div> </div> </body> </html>
export const employees = [{ 'ID': 1, 'FirstName': 'John', 'LastName': 'Heart', 'Phone': '(213) 555-9392', 'Position': 'CEO', 'Email': 'jheart@dx-email.com', 'Address': '351 S Hill St.' }, { 'ID': 2, 'FirstName': 'Olivia', 'LastName': 'Peyton', 'Phone': '(310) 555-2728', 'Position': 'Sales Assistant', 'Email': 'oliviap@dx-email.com', 'Address': '807 W Paseo Del Mar' }, { 'ID': 3, 'FirstName': 'Robert', 'LastName': 'Reagan', 'Phone': '(818) 555-2387', 'Position': 'CMO', 'Email': 'robertr@dx-email.com', 'Address': '4 Westmoreland Pl.' }, { 'ID': 4, 'FirstName': 'Greta', 'LastName': 'Sims', 'Phone': '(818) 555-6546', 'Position': 'HR Manager', 'Email': 'gretas@dx-email.com', 'Address': '1700 S Grandview Dr.' }, { 'ID': 5, 'FirstName': 'Brett', 'LastName': 'Wade', 'Phone': '(626) 555-0358', 'Position': 'IT Manager', 'Email': 'brettw@dx-email.com', 'Address': '1120 Old Mill Rd.' }, { 'ID': 6, 'FirstName': 'Sandra', 'LastName': 'Johnson', 'Phone': '(562) 555-2082', 'Position': 'Controller', 'Email': 'sandraj@dx-email.com', 'Address': '4600 N Virginia Rd.' }, { 'ID': 7, 'FirstName': 'Kevin', 'LastName': 'Carter', 'Phone': '(213) 555-2840', 'Position': 'Shipping Manager', 'Email': 'kevinc@dx-email.com', 'Address': '424 N Main St.' }, { 'ID': 8, 'FirstName': 'Cynthia', 'LastName': 'Stanwick', 'Phone': '(818) 555-6655', 'Position': 'HR Assistant', 'Email': 'cindys@dx-email.com', 'Address': '2211 Bonita Dr.' }, { 'ID': 9, 'FirstName': 'Kent', 'LastName': 'Samuelson', 'Phone': '(562) 555-9282', 'Position': 'Ombudsman', 'Email': 'kents@dx-email.com', 'Address': '12100 Mora Dr' }, { 'ID': 10, 'FirstName': 'Taylor', 'LastName': 'Riley', 'Phone': '(310) 555-7276', 'Position': 'Network Admin', 'Email': 'taylorr@dx-email.com', 'Address': '7776 Torreyson Dr' }];
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, map: { vue: 'npm:vue@2.6.3/dist/vue.esm.browser.js', 'vue-loader': 'npm:dx-systemjs-vue-browser@latest/index.js', 'devextreme': 'npm:devextreme@19.2', 'devextreme-vue': 'npm:devextreme-vue@19.2', jszip: 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.7/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'devexpress-gantt': 'npm:devexpress-gantt', 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, meta: { '*.vue': { loader: 'vue-loader' } }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });