Need highlighting of fields

Hi,

We have certain editable fields in the grid with controls like textbox, dropdown and custom control and these are required. On editing however i am getting required field message but also we need control to be highlighted with red border. This is not happening. Kindly suggest on how to achieve it.

Thanks,
Dileep gagan R

5 Replies 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team October 5, 2020 11:56 AM UTC

Hi Dileep, 

Greetings from Syncfusion Support. 

Based on your query we found that you want to highlight the custom control’s border with the required field message. You can achieve your requirement by adding  ‘e-cus’ class to the custom control. To add the custom class we suggest you to bind the click event to the Grid as demonstrated in the below code snippet, 
App.component.ts 
 
    
        <ejs-grid (click) ='clickFn($event)' #grid id='Normalgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'> 
            <e-columns> 
                             ... 
 
              </e-columns> 
        </ejs-grid> 
 
 
    public ngOnInit(): void { 
        this.data = orderDataSource; 
         
    } 
// Grid’s click event function 
 
clickFn(e){ 
 
setTimeout(function(){ 
 
  let errorEle = this.grid.editModule.formObj.element.querySelectorAll('.e-error'); 
 
if(errorEle.length){ 
   for(let i=0; i< errorEle.length; i++){ 
     
      let errorInputEle = errorEle[i].classList.contains('e-ddl-hidden')? errorEle[i] : this.grid.editModule.formObj.element.querySelectorAll('input.e-error')[i] 
      if(errorInputEle){ 
      if(errorInputEle.classList[0].indexOf('hidden') !=-1){ 
        errorInputEle.parentElement.classList.add('e-cus') //adding class to custom control 
      } 
      else{ 
        errorInputEle.classList.add('e-cus') 
      } 
      } 
} 
} 
 



app.component.css 
 
.e-cus{ 
  border : 2px solid red !important; 
}    
 


Please find the  below sample for more information. 

 
Please get back to us if you need further assistance. 

Regards, 
Shalini M. 


 




DG Dileep gagan R replied to Shalini Maragathavel October 6, 2020 04:50 AM UTC

Hi Dileep, 

Greetings from Syncfusion Support. 

Based on your query we found that you want to highlight the custom control’s border with the required field message. You can achieve your requirement by adding  ‘e-cus’ class to the custom control. To add the custom class we suggest you to bind the click event to the Grid as demonstrated in the below code snippet, 
App.component.ts 
 
    
        <ejs-grid (click) ='clickFn($event)' #grid id='Normalgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'> 
            <e-columns> 
                             ... 
 
              </e-columns> 
        </ejs-grid> 
 
 
    public ngOnInit(): void { 
        this.data = orderDataSource; 
         
    } 
// Grid’s click event function 
 
clickFn(e){ 
 
setTimeout(function(){ 
 
  let errorEle = this.grid.editModule.formObj.element.querySelectorAll('.e-error'); 
 
if(errorEle.length){ 
   for(let i=0; i< errorEle.length; i++){ 
     
      let errorInputEle = errorEle[i].classList.contains('e-ddl-hidden')? errorEle[i] : this.grid.editModule.formObj.element.querySelectorAll('input.e-error')[i] 
      if(errorInputEle){ 
      if(errorInputEle.classList[0].indexOf('hidden') !=-1){ 
        errorInputEle.parentElement.classList.add('e-cus') //adding class to custom control 
      } 
      else{ 
        errorInputEle.classList.add('e-cus') 
      } 
      } 
} 
} 
 



app.component.css 
 
.e-cus{ 
  border : 2px solid red !important; 
}    
 


Please find the  below sample for more information. 

 
Please get back to us if you need further assistance. 

Regards, 
Shalini M. 


 



Thank you, this works !!.. However it triggers only on clicking on other part of grid. but if I click outside of the grid only required message triggers but border doesn't highlight.


SM Shalini Maragathavel Syncfusion Team October 7, 2020 01:49 PM UTC

Hi Dileep, 

Sorry for the inconvenience caused. 

Based on your query we found that you want to highlight the custom control’s border with the required field message. You can achieve your requirement by adding  ‘e-cus’ class to the custom control. To add the custom class we suggest you to bind the load event to the Grid as demonstrated in the below code snippet, 
App.component.ts 
 
   <ejs-grid   (load)="load($event)"  #grid id='Normalgrid' [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar' width='700'> 
            <e-columns> 
               .... 
 
            </e-columns> 
        </ejs-grid> 
 
 
load(){ 
   
    document.addEventListener('click', function (e) { 
      
      setTimeout(function(){ 
  let errorEle = this.grid.editModule.formObj.element.querySelectorAll('.e-error'); 
 
if(errorEle.length){ 
   for(let i=0; i< errorEle.length; i++){ 
     
      let errorInputEle = errorEle[i].classList.contains('e-ddl-hidden')? errorEle[i] : this.grid.editModule.formObj.element.querySelectorAll('input.e-error')[i] 
      if(errorInputEle){ 
      if(errorInputEle.classList[0].indexOf('hidden') !=-1){ 
        errorInputEle.parentElement.classList.add('e-cus') 
      } 
      else{ 
        errorInputEle.classList.add('e-cus') 
      } 
      } 
} 
} 
 
}.bind(this), 100) 
 
    }.bind(this)) 
 
} 
} 

 
Please find the  below sample for more information. 

Please get back to us if you need further assistance. 

Regards, 
Shalini M. 
 




Marked as answer

DG Dileep gagan R October 8, 2020 11:39 AM UTC

Thank you this solves my problem.


TS Thiyagu Subramani Syncfusion Team October 9, 2020 06:43 AM UTC

Hi Dileep, 

Thanks for your update. 

We are happy to hear that the provided solution works at your end. 

Please get back to us, if you need any further assistance. 

Regards, 
Thiyagu S 


Loader.
Up arrow icon