Want Rad Confirm on Selected Item Changed

4 posts, 0 answers
  1. Rahul
    Rahul avatar
    142 posts
    Member since:
    May 2009

    Posted 18 Jan 2010 Link to this post

    Hello i have one combox i want to gives the confirm message "Are you sure you wnt to select ?"  when the user selected or changed the item how to do using selected index changes in rad combox ?


    urgentttt
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jan 2010 Link to this post

    Hello Rahul,

    Try the following approach in order to show radconfirm when changing the selection in combobox.

    aspx:
     
    <telerik:RadComboBox ID="RadComboBox4" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging"
        <Items> 
            <telerik:RadComboBoxItem Text="Item1" /> 
            <telerik:RadComboBoxItem Text="Item2" /> 
            <telerik:RadComboBoxItem Text="Item3" /> 
        </Items> 
    </telerik:RadComboBox> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
    </telerik:RadWindowManager> 

    javascript:
     
        var flag = false
        var text = ""
        function OnClientSelectedIndexChanging(sender, args) { 
            if (!flag) { 
                args.set_cancel(true); 
                radconfirm('Are you sure...?', confirmCallBackFn); 
                text = args.get_item().get_text(); 
            } 
            flag = false
        } 
        function confirmCallBackFn(arg) { 
            if (arg) { 
                var combo = $find('<%=RadComboBox4.ClientID%>'); 
                var item = combo.findItemByText(text); 
                flag = true
                item.select(); 
            } 
        } 

    -Shinu.
  3. sf
    sf avatar
    103 posts
    Member since:
    Apr 2009

    Posted 10 Nov 2010 Link to this post

    hi Shinu I tried your solution it doesn't work for me because my radcombobox is within a gridtemplatecolumn of radgrid control.
    the application complaints that the combobox cannot be found.  I need to achieve 2 things:
    1. find the combobox so that the solution works in my scenario
    2. make the confirmation box only popsup if the selectedvalue of the combobox is "Delete"

    if you can help with my headaches it will be great, thanks in advance
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Nov 2010 Link to this post

    Hello,

    I modified the code based on your requirement. I hope the following code snippet will help you to achieve your requirement.

    Java Script:
    <script type="text/javascript">
        var flag = false;
        var combo;
        function OnClientSelectedIndexChanging(sender, args) {    
                combo = sender;
                text = args.get_item().get_text();
                if (text == "Delete") {
                    if (!flag) {
                        args.set_cancel(true);
                        radconfirm('Are you sure...?', confirmCallBackFn);
                    }
                }
            flag = false;
        }
        function confirmCallBackFn(arg) {
            if (arg) {
                var item = combo.findItemByText("Delete");
                flag = true;        
                item.select();
            }
        }
    </script>
    Note: The RadComboBox is placed inside the ItemTemplate of GridTemplateColumn.


    -Shinu.
Back to Top