We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to define a column as a number in a particular range ?

Thread ID:

Created:

Updated:

Platform:

Replies:

146104 Jul 19,2019 06:03 PM UTC Jul 24,2019 09:06 PM UTC Vue 4
loading
Tags: Data Grid
Silvio
Asked On July 19, 2019 06:03 PM UTC

Hi,

I have a ejs-grid that contains a column that is bound to a variable that is numeric.
When this column is in edit mode I'd like the user can't type characters different from digits (0-9) and also I'd like to specify at run-time a range among witch the typed number should stay (for example, say min 1 and max a variable set in the Vue.data).
I've tried a lot of examples in the documentation but I can't figure out how to achieve this.
I've used ":format="N"" to specify that the column is a number but the user still can type other chars.
I've provided a validationRules but I'm only able to specify that the column is required but I can't find in your examples a section that clearly esplains me all the possible validationRules I can attach to a column.
So I need an help from anyone, how to set a column as a number, required, and with min and max value set at runtime (not fixed with constants).

Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 22, 2019 01:08 PM UTC

Hi Silvio, 

Greetings from Syncfusion support. 

We can achieve your requirement by setting the number column value as numeric edit type component to prevent to enter the other characters instead of numbers. We can set the min max values through the validation rules of columns API in Grid. 

Refer the below code example. 


<template> 
    <div id="app"> 
        <ejs-grid id="Grid" 
                  ref="grid" 
                  :dataSource="data" 
                  :editSettings="editSettings" 
                  :allowPaging="true" 
                  :toolbar="toolbar" 
                   
> 
            <e-columns> 
                <e-column field="OrderID" headerText="Order ID" isPrimaryKey="true" width="90"></e-column> 
                <e-column field="CustomerID" headerText="Customer ID" width="120"></e-column> 
                <e-column field="Freight" 
                          headerText="Freight" 
                          editType="numericedit" 
                          :validationRules="customerIDRules" 
                          type="number" 
                          width="90"></e-column> 
                <e-column field="ShipCountry" headerText="Ship Country" width="120"></e-column> 
            </e-columns> 
        </ejs-grid> 
    </div> 
</template> 
 
<script> 
import Vue from "vue"; 
import { GridPlugin, Page, Toolbar, Edit } from "@syncfusion/ej2-vue-grids"; 
import { DropDownListPlugin } from "@syncfusion/ej2-vue-dropdowns"; 
import { DropDownButtonPlugin } from "@syncfusion/ej2-vue-splitbuttons"; 
import { ButtonPlugin } from "@syncfusion/ej2-vue-buttons"; 
import { data } from "./datasource"; 
 
Vue.use(GridPlugin); 
Vue.use(ButtonPlugin); 
Vue.use(DropDownListPlugin); 
Vue.use(DropDownButtonPlugin); 
 
export default { 
  data() { 
    return { 
      waterMark: "Select a export option", 
      height: "220px", 
       
      data: data, 
      editSettings: { 
        allowEditing: true, 
        allowAdding: true, 
        allowDeleting: true 
      }, 
      toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"], 
      customerIDRules: { required: true, min: 0, max: 1000 } 
    }; 
  }, 
  provide: { 
    grid: [Page, Toolbar, Edit] 
  }, 
  methods: {} 
}; 
</script> 

  
We have prepared a simple sample in the following link 


Refer the help documentation. 




Regards, 
Thavasianand S. 


Silvio
Replied On July 22, 2019 07:07 PM UTC

Thank you!

Renjith Singh Rajendran [Syncfusion]
Replied On July 24, 2019 01:01 PM UTC

Hi Silvio, 
  
We are happy to hear that your requirement has been achieved. 
  
Please get back to us if you need further assistance. 
  
Regards, 
Renjith Singh Rajendran. 


Silvio
Replied On July 24, 2019 09:06 PM UTC

I have still another little question.
How is it possible to indicate that the bound variable is an integer variable and not a floating point one?
I'd like the user is able to type only digits (0-9) and not also the dot to have decimal values.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon