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. Image for the cookie policy date

Custom Validation Get all fields

Hi,

How can we get values of whole grid line while doing custom validation? 
say for example i am having 3 columns Name, Duration and factor i need to add custom validation in factor as it should not be more than Duration so i need both value i.e duration and factor.

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team June 12, 2019 09:12 AM UTC

Hi Sandeep, 

Thanks for contacting Syncfusion support. 

We have validated your requirement. You can achieve your requirement by using the below way. Please find the below code snippet and sample for your information. 

export class Editing extends SampleBase { 
    constructor() { 
        super(...arguments); 
        this.toolbarOptions = ['Add', 'Edit','Update', 'Delete']; 
        this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true,}; 
        this.validationRules = { required: true }; 
        this.orderidRules = { required: true, number: true }; 
        this.pageSettings = { pageCount: 5 }; 
        this.customerIDRules = { 
    minLength: [this.customFn, 'Need atleast 5 letters'], 
    required: true 
  }; 
    } 
     customFn(args) { 
      var editRow = parentsUntil (args.element, 'e-row'); //here you can get the values the other input field value 
      return getValue('value', args).length >= 5; 
  }; 
     
    render() { 
        return (<div className='control-pane'> 
        <div className='control-section'> 
         . . . 
              <ColumnDirective field='CustomerName' headerText='Customer Name' width='150' validationRules={this.customerIDRules}></ColumnDirective> 
      . . . 
          </GridComponent> 
        </div> 
      </div>); 
    } 

render(<Editing />, document.getElementById('sample')); 


Please get back to us if you need further assistance. 

Regards, 
Thavasianand S. 



LA License Admin June 12, 2019 11:48 AM UTC

Hi,

Thanks.

In the above example can you please get the orderId value as i am not getting how to retrieve values from editRow.


PS Pavithra Subramaniyam Syncfusion Team June 13, 2019 07:01 AM UTC

Hi Sandeep, 
 
You can get the other field values in the edit row by using the below way. Please refer to the below code example and sample link for more information. 
 
[index.jsx] 
customFn(args) { 
      var editRow = parentsUntil (args.element, 'e-row'); //here you can get the values the other input field value 
      var Grid_Id = parentsUntil (args.element, 'e-grid').id; 
      console.log(editRow.querySelector("#"+Grid_Id+"OrderID").value);   
      return getValue('value', args).length >= 5; 
  }; 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


Loader.
Up arrow icon