Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1005
How to set focus in RowEditTemplate
posted

I would like to set the focus to a particular control when opening the RowEditTemplate on a WebDataGrid. Can you share some code that accomplishes this?

Thanks, Dave

Parents
  • 8160
    posted

    Hello davefevold,

    You can handle TemplateOpened event and to set the focus of the control you want. The following code will set focus to the second WebNumericEditor2  from the RowEditingTemplate


    <script type="text/javascript">
            var editor;

            function WebDataGrid1_TemplateOpened(sender, eventArgs) {
                editor.setFocus();
            }

            function WebNumericEditor2_Initialize(sender, eventArgs) {
                editor = sender;
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False"
                DataSourceID="SqlDataSource1">
                <Columns>
                    <ig:BoundDataField DataFieldName="CategoryID" Key="CategoryID">
                        <Header Text="CategoryID" />
                    </ig:BoundDataField>
                    <ig:BoundDataField DataFieldName="CategoryName" Key="CategoryName">
                        <Header Text="CategoryName" />
                    </ig:BoundDataField>
                </Columns>
                <Behaviors>
                    <ig:EditingCore>
                        <Behaviors>
                            <ig:RowEditingTemplate>
                                <EditModeActions MouseClick="Double" />
                                <Template>
                                    <div style="background-color: Red; width: 250px; height: 250px">
                                        <ig:WebNumericEditor ID="WebNumericEditor1" runat="server">
                                        </ig:WebNumericEditor>
                                        <ig:WebNumericEditor ID="WebNumericEditor2" runat="server">
                                            <ClientEvents Initialize="WebNumericEditor2_Initialize" />
                                        </ig:WebNumericEditor>
                                    </div>
                                </Template>
                                <RowEditingClientEvents TemplateOpened="WebDataGrid1_TemplateOpened" />
                            </ig:RowEditingTemplate>
                        </Behaviors>
                    </ig:EditingCore>
                    <ig:RowSelectors>
                    </ig:RowSelectors>
                </Behaviors>
            </ig:WebDataGrid>

    I hope this help

Reply Children