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

.click error with radconfirm

3 Answers 96 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Pei Chen
Top achievements
Rank 1
Pei Chen asked on 06 Jan 2010, 02:23 PM

I have a radToolBar that I want to show radconfirm when toolbar buttons click, once confirmed, post back to server and execute a function there. 

 

 

function OnToolBarButtonClicked(sender, args) {

 

args.set_cancel(

true);

 

counter = counter + 1;

alert(counter);

 

stopTimer();

btn = args.get_item();

bar = sender;

 

 

 

 

if (btn.get_commandName() == 'Delete') {

 

document.getElementById(

"actionButtonIndex").value = 0

 

radconfirm(

'Are you sure you want to delete the job(s) permanently?', CallBackFn, 330, 100, '', 'Delete Job');

 

 

    }

}

 

 

function CallBackFn(args) {

 

 

var ToolBar = $find("<%= RadToolBar1.ClientID %>");

 

 

 

if (args == true) {

 

btn.click();

 

    }

 

}

 

 

<

 

telerik:RadToolBar ID="RadToolBar1" runat="server" style="display:block; float:none" Skin="Vista" OnClientButtonClicking="OnToolBarButtonClicked" OnButtonClick="ExecPostBackClick">

 

 

 

<Items>

 

 

<telerik:RadToolBarButton runat="server" ImageUrl="Style/Images/menudelete.gif" CommandName="Delete" ToolTip="Delete" />

 

<

 

telerik:RadToolBarButton runat="server" ImageUrl="style/images/menuEnable.gif" CommandName="Enable" ToolTip="Enable" />

 

 

<telerik:RadToolBarButton runat="server" ImageUrl="style/images/menuDisable.gif" CommandName="Disable" ToolTip="Disable" />

 

 

</Items> 

 

 

 

</telerik:RadToolBar>

I noticed that the btn.click doesn't do anything.  It doesn't seem like it posts back to the server either.  I added a counter to debug and found out that btn.click hit OnClientButtonClick instead of server's OnButtonClick.  Is there a workaround that you can provide to me or point me out a better way to code what I want to do.  Thanks yoU!  

 

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Jan 2010, 03:29 PM
Hello,

Try the following code snippet and see whether it helps.

JavaScript:
 
    var check = true
    function OnClientButtonClicking(sender, args) { 
        if (check) { 
            args.set_cancel(true); 
        } 
        btn = args.get_item(); 
        bar = sender; 
        if (btn.get_commandName() == 'Delete' && check) { 
            radconfirm('Are you sure you want to delete the job(s) permanently?', CallBackFn, 330, 100, '''Delete Job'); 
        } 
    } 
    function CallBackFn(args) { 
        var ToolBar = $find("<%= reportToolBar.ClientID %>"); 
        if (args == true) { 
            check = false
            btn.click(); 
        } 
    } 
Attach OnClientButtonClicking event to RadToolBar.

-Shinu.
0
Pei Chen
Top achievements
Rank 1
answered on 06 Jan 2010, 03:50 PM
Hi Shinu, that worked out beautifully!!!  You're a genius!  Thank you soooooooooooo much!!!!!   :)
0
Pei Chen
Top achievements
Rank 1
answered on 11 Jan 2010, 06:24 PM

var check = true;  
 
function OnToolBarButtonClicked(sender, args) {   
var selectedRows = $find("<%= rg1.ClientID %>").get_masterTableView().get_selectedItems();  
 
         if (selectedRows.length > 0) {          
                 if (check) {  
                     args.set_cancel(true);  
                 }  
 
                 btn = args.get_item();  
 
                 if (btn.get_commandName() == 'View' && check) {  
 
                        btn.click();  
                        check = false;  
                 }  
                 
         }  
     }  
 
 
     function CallBackFn(args) {  
         if (args == true) {  
                btn.click();  
     
           
        }  
    }  
 
'============ Code Behind ======================================  
 
Public Sub OnMenuPostBackClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadMenuEventArgs)  
 
Case "View"  
 
                For Each item In rg1.MasterTableView.Items  
                    If item.Selected = True Then  
 
                        jobNm = item.GetDataKeyValue("JobName").ToString()  
 
 
                    End If  
 
                Next  
 
                
        End Select  
 
End Sub  
 
'=====================  ASPX ============================  
 
<telerik:RadToolBar ID="RadToolBar1" runat="server" style="display:block; float:none" Skin="Vista" OnClientButtonClicking="OnToolBarButtonClicked"  OnButtonClick="ExecPostBackClick">   
      
        <Items> 
               
             <telerik:RadToolBarButton runat="server" ImageUrl="style/images/window_view.gif"  CommandName="View" ToolTip="View" />        
        </Items> 
              
    </telerik:RadToolBar> 

Maybe not so beautifully...
It worked as it supposed to with check toggling.  but when it hits btn.click(); it gives "Stack overflow at line: 99".  Any ideas?
Tags
ToolBar
Asked by
Pei Chen
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Pei Chen
Top achievements
Rank 1
Share this question
or