取消被Ajaxified的Toolbar中某个按钮的Ajax功能

方法一:

在RequestStart事件中直接处理。

 function RadAjaxManager1_OnRequestStart(sender, args) {
            var eventTarget = args.get_eventTarget(); //the UniqueID of the control which triggers the ajax
            var toolBar = $find("<%= RadToolBar1.ClientID %>");

            if (eventTarget.replace(/\$/ig, "_") == toolBar.get_id()) { //check if this is the toolbar
                var index = parseInt(args.get_eventArgument()); //the index of the button which was clicked
                var button = toolBar.get_items().getItem(index);
                if (button.get_text() == "导出") { // cancel the ajax
                    args.set_enableAjax(false);
                }
            }
        }   


方法二:

Step 1:利用HiddenField在Toolbar的ClientButtonClicking事件中记录被点击的按钮

 function onToolBarClientButtonClicking(sender, args) {
            var button = args.get_item();
            var btnValue = button.get_value();
            var HFButton = document.getElementById("<%= hfButton.ClientID %>");
            if (HFButton) {
                HFButton.value = btnValue;
            }
}


Step 2:在RequestStart事件中进行处理。

function RadAjaxManager1_OnRequestStart(sender, args) {
            if (args.get_eventTarget().indexOf("RadToolBar1") >= 0) {
                var HFButton = document.getElementById("<%= hfButton.ClientID %>");
                if (HFButton) {
                    var currentValue = HFButton.value;
                    if (currentValue == "Export")
                        args.set_enableAjax(false);
                    else
                        args.set_enableAjax(true);
                }
            }
        }


 

你可能感兴趣的:(Telerik)