This is a migrated thread and some comments may be shown as answers.

[Solved] Opening Multiple Edit Forms On Enter

3 Answers 200 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Josan Thomas
Top achievements
Rank 1
Josan Thomas asked on 16 Dec 2009, 10:58 AM
I have a grid control with Form template for editing, with EditMode="PopUp" and PopUpSettings-Modal="true". Now while click on add or edit button, edit template from(popup) will open. Then just press on enter button on keyboard, will open another edit template form.
My observation is even after opening edit form, control focus remains in parent. So while opening edit form I am explicitly set focus on control in edit form, and found working fine. But after click anywhere in edit form except any controls or just drag edit form, then press enter, will open new edit form.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Dec 2009, 11:48 AM
Hello Jason Thomas,

You can attach client-side 'OnCommand' event and check for whether editform is opened and if so cancel the command if it is "Edit" or "InitInsert".

JavaScript:
 
<script type="text/javascript"
    function OnCommand(sender, args) { 
        if (args.get_commandName() == "InitInsert" || args.get_commandName() == "Edit") { 
            if (sender._editIndexes.length != 0) { 
                args.set_cancel(true); 
            } 
        } 
    } 
</script> 

Thanks,
Princy.
0
Josan Thomas
Top achievements
Rank 1
answered on 17 Dec 2009, 01:08 PM
Hi Princy
Thanks for your immediate reply.
The above code is not works for me.
editindexes.length will be 0 on add mode. It will change only on edit.
I am facing above issue on adding new item. that time editindexs will be 0

Regards
Josan.
0
Radoslav
Telerik team
answered on 18 Dec 2009, 02:29 PM
Hello Josan Thomas,

You could use client side function get_isItemInserted() of RadGrid MasterTable. It indicates if the GridTableView is currently in insert mode.  So your previous code could be modified like that:

<script type="text/javascript">
    function OnCommand(sender, args) {
        if (args.get_commandName() == "Edit") {
            if (sender._editIndexes.length != 0) {
                args.set_cancel(true);
            }
        }
        if (args.get_commandName() == "InitInsert") {
            var grid = $find("<%=RadGrid1.ClientID %>");
            if (grid.get_masterTableView().get_isItemInserted() == true) {
                args.set_cancel(true);
            }
        }
    }
</script>

I hope this helps.

Kind regards,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Josan Thomas
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Josan Thomas
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or