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

focus setting on custom dialog

Hello,

I'm working on custom dialog and I want to set up default focus on a specific column which is blank column below.












I wrote this code but doen't work.

             var numeric = $("#blank").ejNumericTextbox("instance");  
                numeric._hiddenInput.focus();   



I attach my sample code.  Could you please let me know what's wrong is my code?

Regards,
Yukiko



8 Replies

YI Yukiko Imazu March 5, 2019 06:28 PM UTC

Here's my sample solution

Attachment: test_7d16e270.7z


VN Vignesh Natarajan Syncfusion Team March 6, 2019 10:33 AM UTC

Hi Yukiko, 
 
Thanks for using Syncfusion products. 
 
Query: “I want to set up default focus on a specific column which is blank column below” 
 
From your query, we understand that you need to focus the blank input element in the Dialog template of ejGrid. We have achieved your requirement using open event of ejDialog. Refer the below code example 
 
function onGridActionCompleteEvent(args) { 
……………………………………………………….. 
            if (args.model.editSettings.editMode == "dialogtemplate") { 
……………………………………………………………………………. 
 
                $.ajax({ 
                    type: "POST", 
                    url: "Default.aspx/DropDown", 
                    contentType: "application/json; charset=utf-8", 
                    dataType: "json", 
                    success: function (value) { 
                      
                        $("#priceId").ejDropDownList({ 
                            dataSource: value.d, 
                            fields: { value: "priceId", text: "price1" }, 
                            width: "100%" 
                        }); 
                     
                    }, 
                    error: function (e) { 
                        alert(e); 
                    } 
                }); 
 
                var dia = $('#<%= Grid1.ClientID %>'+"_dialogEdit").ejDialog("instance") // take instance of ejDialog  
                dia.setModel({ 
                    //bind open event to ejDialog 
                    open: function (args) {                        
                            var numeric = $("#blank").ejNumericTextbox("instance");    
                            numeric.element.siblings('input:visible').focus(); // focus the input element                   
                    } 
                    }) 
 
            } 
} 
    } 
 
Refer the below screenshot for the output 
 
 
 
 
Refer our API documentation for your reference 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 
 



YI Yukiko Imazu March 6, 2019 02:51 PM UTC

Hi Vignesh,

Thank you for your support.
We were able to achieve out requirement.

Regards,
Yukiko


VN Vignesh Natarajan Syncfusion Team March 7, 2019 04:23 AM UTC

Hi Yukiko, 

Thanks for the update. 

We are glad to hear that your query has been resolved  by our solution.  

Please get back to us if you have further queries.  

Regards, 
Vignesh Natarajan. 



YI Yukiko Imazu March 7, 2019 09:07 PM UTC

Hi,

I also have one more question.

Is it possible to show dialog without any focus on any columns?
How do we remove default focus setting on the dialog?

Regards,
Yukiko


VN Vignesh Natarajan Syncfusion Team March 8, 2019 10:26 AM UTC

Hi Yukiko, 
 
Query: “How do we remove default focus setting on the dialog?” 
 
We have achieved your query to remove the focus from ejDialog edit form by blur() method. Reefer the below code example 
 
function onGridActionCompleteEvent(args) { 
………………………………………………………………. 
 
                $.ajax({ 
……………………………………………………….. 
                }); 
 
                 var dia = $('#<%= Grid1.ClientID %>'+"_dialogEdit").ejDialog("instance") 
                dia.setModel({ 
                    //bind open event to ejDialog 
                    open: function (args) {                        
                        var numeric = $("#SubA").ejCurrencyTextbox("instance");    
                        numeric.element.blur();                 
                    } 
                    }) 
   } 
    } 
} 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 



YI Yukiko Imazu March 8, 2019 02:40 PM UTC

Hi Vignesh,

Thank you for your response.
Our issue was resolved.

Best Regards,
Yukiko


VN Vignesh Natarajan Syncfusion Team March 11, 2019 06:36 AM UTC

Hi Yukiko, 
 
Thanks for the update.  
 
We are glad to hear that your query has been resolved by our solution. 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon