如何禁用某些控制,直到更新成功? [英] How to disable certain controls until update is successful?

查看:143
本文介绍了如何禁用某些控制,直到更新成功?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 GridView控件和pretty很多工作一切工作正常。

I'm working with a GridView and pretty much everything is working fine.

剩下的唯一的事情是确保当我在一个文本字段我打字,所有其他文本字段提交按钮中我的 GridView控件除外当前其他行被停用,直到我的更新完成。

The only thing left is to make sure that when I'm typing in one text field, all other text fields and Submit buttons in my GridView on other rows except current one get disabled until my update is done.

这是我的 GridView控件的生成 HTML code:

This is my GridView's generated html code:

<div id="gridView">
                     <div>
        <table cellspacing="0" border="1" style="border-color:Red;border-collapse:collapse;position:absolute; top: 290px;" id="MainContent_grvIsoSearchResults" rules="all">
            <tbody><tr>
                <th scope="col">ISONUM</th><th scope="col">OFFICE NAME</th><th scope="col">REGION</th><th scope="col">DIVISION</th><th scope="col">EMAIL ADDRESS</th>
            </tr><tr>
                <td>
                                    <span style="display:inline-block;width:70px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoNum_0">222222222 </span>
                                </td><td>
                                    <span style="display:inline-block;width:200px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoOfficeName_0">My Test</span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvRegion_0">99</span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvDivision_0">11111</span>
                                </td><td>
                                    <input type="text" style="width:200px;" onclick="ResetMessage();" id="MainContent_grvIsoSearchResults_txtgvEmailAddress_0" value="mytest@google.com" name="ctl00$MainContent$grvIsoSearchResults$ctl02$txtgvEmailAddress">
                                    <input type="submit" id="MainContent_grvIsoSearchResults_btnEmailUpdate_0" value="Update" name="ctl00$MainContent$grvIsoSearchResults$ctl02$btnEmailUpdate">
                                </td>
            </tr><tr>
                <td>
                                    <span style="display:inline-block;width:70px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoNum_1">CB2222001 </span>
                                </td><td>
                                    <span style="display:inline-block;width:200px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoOfficeName_1">DENNIS PETROVIC          </span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvRegion_1"></span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvDivision_1">99801</span>
                                </td><td>
                                    <input type="text" style="width:200px;" onclick="ResetMessage();" id="MainContent_grvIsoSearchResults_txtgvEmailAddress_1" value="dennis@dlgent.com" name="ctl00$MainContent$grvIsoSearchResults$ctl03$txtgvEmailAddress">
                                    <input type="submit" id="MainContent_grvIsoSearchResults_btnEmailUpdate_1" value="Update" name="ctl00$MainContent$grvIsoSearchResults$ctl03$btnEmailUpdate">
                                </td>
            </tr><tr>
                <td>
                                    <span style="display:inline-block;width:70px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoNum_2">FT2222001 </span>
                                </td><td>
                                    <span style="display:inline-block;width:200px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvIsoOfficeName_2">DENNIS PETROVIC          </span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvRegion_2"></span>
                                </td><td>
                                    <span style="display:inline-block;width:50px;text-align:center" id="MainContent_grvIsoSearchResults_txtgvDivision_2">99801</span>
                                </td><td>
                                    <input type="text" style="width:200px;" onclick="ResetMessage();" id="MainContent_grvIsoSearchResults_txtgvEmailAddress_2" value="dennis@dlgent.com" name="ctl00$MainContent$grvIsoSearchResults$ctl04$txtgvEmailAddress">
                                    <input type="submit" id="MainContent_grvIsoSearchResults_btnEmailUpdate_2" value="Update" name="ctl00$MainContent$grvIsoSearchResults$ctl04$btnEmailUpdate">
                                </td>
            </tr>
        </tbody></table>
    </div>

我该怎么办呢?

感谢您

推荐答案

尝试code波纹管;

Try code bellow;

$(function () {
//this is based on your code only, this could be done a lot prettier if you added a custom attribute to each
// <tr> like let's say - myrownumber ... then there is no need to get a child and find rownumber on the fly, 
//an everything would be prettier; 
$('input').live("focus", function () {

    var rowId = $(this).attr('id');
    var selectedRow = rowId.substring((rowId.length - 1), rowId.length);
    $('tr').each(function () {
        //find rownum 
        var inputId = $(this).find('input').attr('id');

        if (inputId != null && typeof inputId !== "undefined") {
            var row = inputId.substring((inputId.length - 1), inputId.length);

            if (row !== selectedRow) {
                $(this).find('input').prop("disabled", true);
            }
        }
    });

});
//once again this is based on your code, this can be done more ellegantly if you implement smarter naming 
//make all buttons of same class, etc... for easier selection
$('input[type=submit]').live("click", function () {
    //submit your request and get response 
    //if response success 
    $('tr').each(function () {
        $(this).find('input').prop("disabled", false);
    });

});

});

这篇关于如何禁用某些控制,直到更新成功?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆