Press enter the dialog auto close

I am using syncfuson angular dialog, There is a filter bar in right grid, when press enter key, I want to search the right grid, but the dialog closed, what should I do for this issue ? It seems that filter search is conflicted with submit button. Do I must use dialog footer template for submit button, not buttons property?


7 Replies

KV Karthikeyan Viswanathan Syncfusion Team August 28, 2018 05:53 AM UTC

Hi lorryl, 
 
Thanks for contacting Syncfusion support. 
 
Query 1: I am using syncfusion angular dialog, There is a filter bar in right grid, when press enter key, I want to search the right grid, but the dialog closed, what should I do for this issue ? 

We were unable to find out the exact root cause of this issue. Also, we suspect that the issue is raised due to handle the dialog’s close action in keydown event in your application. So, please check your application whether the dialog hide is handled in key action or not. 

Still, you have an issue then please share the below details. It will help us to provide a solution at earlier. 
  • Share the issue reproducing sample if possible.
  • Share the code snippet which it is help to reproduce this issue.

Query 2: Do I must use dialog footer template for submit button, not buttons property? 
Yes, currently we are not having an option to provide the footer button as submit type. We will consider this as an improvement in our side and it will be included in our upcoming main release for volume 3, 2018 SP1 release. 
 
As a workaround, you can achieve your requirement  by using footer template API. 


 
Regards, 
Karthikeyan V. 



LO lorryl September 7, 2018 08:31 AM UTC

Hi, 

I uploaded a demo, the dialog is a list form with a grid list only. 

like the below picture, the dialog are auto closed when I press enter for filtering grid.



Attachment: demodialog_b9b3fee3.rar


KV Karthikeyan Viswanathan Syncfusion Team September 10, 2018 11:33 AM UTC

Hi lorryl, 
 
Thanks for contacting Syncfusion support. 
 
As per standard behavior, while pressing enter from input field inside dialog, primary button action will be called. 

To overcome this, we suggest the below possible solutions. 
 
(i).  Based on the conditions, you can set args.cancel as true in dialog beforeClose event. This will restrict to close the dialog. 

public beforeDialogClose = function (args: any): void { 
    if ((document.getElementById('VoucherNo_filterBarcell') as HTMLInputElement).value === '') { 
         args.cancel = true 
    } 
} 
 
 
(ii). Else, you can change the footer button as non-primary button. 
 
public buttons: Object = [ 
    { 
      'click': this.hideDialog.bind(this), 
      buttonModel: { 
        content: 'OK', 
        // isPrimary: true    // Remove this configuration 
      } 
    }, 
    { 
      'click': this.hideDialog.bind(this), 
      buttonModel: { 
        content: 'Cancel' 
      } 
    } 
]; 
 

 
 
Regards, 
Karthikeyan V.  



LO lorryl September 12, 2018 03:38 AM UTC

If I remove the code "isPrimary = true", the ok button will no color. Any idear ?


KV Karthikeyan Viswanathan Syncfusion Team September 12, 2018 04:49 AM UTC

Hi lorryl,  
 
Based on your scenario, you can achieve this color changes by using cssClass property.  
 
Please refer the below code example:  

<code> 
public buttons: Object = [ 
    { 
      'click': this.hideDialog.bind(this), 
      // Accessing button component properties by buttonModel property 
      buttonModel: { 
        content: 'OK', 
        cssClass: 'e-primary' 
      } 
    }, 
    { 
      'click': this.hideDialog.bind(this), 
      buttonModel: { 
        content: 'Cancel' 
      } 
    } 
  ]; 

</code> 


Regards, 
Karthikeyan V. 



LO lorryl September 12, 2018 05:47 AM UTC

It's very helpful, thank you man.


KV Karthikeyan Viswanathan Syncfusion Team September 12, 2018 06:08 AM UTC

Hi lorryl, 
 
Thanks for the update. 
 
We are glad to hear that your issue has been resolved. 
 
Regards, 
Karthikeyan V. 


Loader.
Up arrow icon