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

format string issue

Thread ID:

Created:

Updated:

Platform:

Replies:

148045 Oct 2,2019 07:33 AM UTC Oct 4,2019 11:37 AM UTC ASP.NET Core - EJ 2 3
loading
Tags: DataGrid
Siti Emayati Murni Saddun Zuber
Asked On October 2, 2019 07:33 AM UTC

hi,
i cannot find the solution for problem below.
if i have enter the valid format it still throw an error
format = ####.##.####.
allowTextWrap="false"
toolbar="@(new List() { "Add", "Edit", "Delete","ExcelExport"})"
toolbarClick="toolbarClick"
allowPaging="true"
allowSorting="true"
allowReordering="true"
allowSelection="true"
allowGrouping="false"
allowFiltering="true"
allowExcelExport="true"
showColumnMenu="true"
created="created"
allowResizing="true"
load="load"
actionBegin="actionBegin">
allowEditing="true"
allowDeleting="true"
mode="Dialog"
showDeleteConfirmDialog="true">
s
defaultValue="@ViewBag.Guid" showInColumnChooser="false">
defaultValue="@ViewBag.UserId">
isPrimaryKey="true" validationRules="@(new { required = false })"
template="#template3"
defaultValue="@ViewBag.Guid" allowEditing="false" showInColumnChooser="false" isIdentity="true">
}
function load() {
this.columns[0].validationRules = { required: true, length: [customFn, 'should be 12 number only'], format: [myFunction, 'follow the format ####.##.####'], number: [true, 'Required Numeric value'] };
//this.columns[0].format = { type: 'string', format: '####.##.####' };
this.columns[3].format = { type: 'date', format: 'dd/MM/yyyy' }; // set your customize date format based on your column
this.columns[3].validationRules = { required: true, minDate: [myFun1, 'Start Date must less than End Date'] };
this.columns[4].format = { type: 'date', format: 'dd/MM/yyyy' }; // set your customize date format based on your column
this.columns[4].validationRules = { required: true, minDate: [myFun2, 'End Date must greater than Start Date'] };
}
function myFun1(args) {
var entered = args.value.split("/");
var grid = document.getElementById("Grid").ej2_instances[0];
var endDate1 = document.getElementById(grid.element.id + grid.columns[4].field).value;
var enddatesplitted = endDate1.split("/");
if (new Date(entered[1] + '/' + entered[0] + '/' + entered[2]) >= (new Date()).setHours(0, 0, 0, 0)) {
return new Date(entered[1] + '/' + entered[0] + '/' + entered[2]) <= new Date(enddatesplitted[1] + '/' + enddatesplitted[0] + '/' + enddatesplitted[2]);
}
}
function myFun2(args) {
var entered = args.value.split("/");
var grid = document.getElementById("Grid").ej2_instances[0];
var startDate1 = document.getElementById(grid.element.id + grid.columns[3].field).value;
var startDateplitted = startDate1.split("/");
if (new Date(entered[1] + '/' + entered[0] + '/' + entered[2]) >= (new Date()).setHours(0, 0, 0, 0)) {
return new Date(entered[1] + '/' + entered[0] + '/' + entered[2]) >= new Date(startDateplitted[1] + '/' + startDateplitted[0] + '/' + startDateplitted[2]);
}
}
function myFunction(args)
{
return args['value'].format == "9999.99.9999";
}
function customFn(args) {
return args['value'].length == 12;
}

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On October 3, 2019 11:35 AM UTC

Hi Siti,  

Greetings from Syncfusion.  

We could see the custom validation function for the format is not handled properly and you have simply checked its length which is the cause of the problem. We suggest to use the regex to check the required format within the custom function. Refer to the following code example.  

function myFunction(args) 
{ 
 return /\b\d{4}\.\d{2}\.\d{4}\b/.test(args['value']); 
} 
function load(args) { 
  this.columns[0].validationRules = { required: true, length: [customFn, 'should be 12 number only'], format: [myFunction, 'follow the format ####.##.####'] }; 
} 

  
Regards,  
Seeni Sakthi Kumar S 


Siti Emayati Murni Saddun Zuber
Replied On October 4, 2019 09:52 AM UTC

Hai Seeni 
Tq for your respond.it's worked

regards
Ema

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On October 4, 2019 11:37 AM UTC

Hi Siti,  
  
We are happy to hear that your requirement has been achieved and you are good to go.

Please get back to us, if you require further assistance on this. 
  
Regards,  
Seeni Sakthi Kumar S 


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