Problems getting input settings on the client

12 posts, 3 answers
  1. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 29 May 2009 Link to this post

    Okay here goes.
    I can't seem to obtain a ref to any of my input settings on the client via the input manager.

    Here's what I'm seeing in my intellisense

    -        $find('RadInputManager').get_inputSettings()    {...}    Object
    •         [Methods]        
    •         RadInputManager_NumericSettings    null    Variant
    •         RadInputManager_TextSettings    null    Variant

    Here's my markup:
         <%-- The following TextBox is required by the InputManager --%>  
        <asp:TextBox ID="TextBox1" runat="server" Visible="false" />  
             
        <telerik:RadInputManager ID="RadInputManager" runat="server" Skin="Vista"
            <telerik:NumericTextBoxSetting BehaviorID="NumericSettings" InitializeOnClient="true" Type="Number" DecimalDigits="1" GroupSizes="3" GroupSeparator="," PositivePattern="n" NegativePattern="-n">  
                <TargetControls> 
                    <telerik:TargetInput ControlID="TextBox1" /> 
                </TargetControls> 
            </telerik:NumericTextBoxSetting> 
            <telerik:TextBoxSetting BehaviorID="TextSettings" InitializeOnClient="true"  > 
                <TargetControls> 
                    <telerik:TargetInput ControlID="TextBox1" /> 
                </TargetControls> 
            </telerik:TextBoxSetting> 
        </telerik:RadInputManager> 

    Ideally I'd like to be able to do this
                    var numericSettings = $find('RadInputManager').get_inputSettings('NumericSettings'); 
                    Array.forEach(elements, function(element) { 
                        numericSettings.addTargetInput(element.id); 
                    });

    I've since also tried the following to see if using this technique would grant me access to the input settings on the client but the settings remain null. I assume both the techniques I've presented here pretty much evaluate to the same thing.
        <script runat="server">   
              
                void Page_Init(object sender, EventArgs e){  
                    RadInputManager input = new RadInputManager();  
                    input.ID = "RadInputManager1";  
                    input.Skin="Vista";  
                    NumericTextBoxSetting numSet = new NumericTextBoxSetting();  
                    numSet.BehaviorID = "NumericSettings";  
                    input.InputSettings.Add(numSet);  
                    input.InputSettings[0].TargetControls.Add(new TargetInput(TextBox1.UniqueID, true));  
                    this.Page.Form.Controls.Add(input);  
                }  
           
    </script>   


    Cheers.
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 30 May 2009 Link to this post

    Hi Matt,

    Here is a page that works as expected:


    <%@ Page Language="C#" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
    <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
    <title>RadControls for ASP.NET AJAX</title> 
    </head> 
    <body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
     
    <p>TextBoxes associated with RadInputManager on the server:</p> 
     
    number: <asp:TextBox ID="TextBox1" runat="server" Text="1" /> 
    date: <asp:TextBox ID="TextBox2" runat="server" Text="1/1/2009" /> 
     
    <p>TextBoxes associated with RadInputManager on the client: 
    <asp:Button ID="Button1" runat="server" OnClientClick="return associate()" Text="click to associate" /> 
    </p> 
     
    number: <asp:TextBox ID="TextBox3" runat="server" Text="2" /> 
    date: <asp:TextBox ID="TextBox4" runat="server" Text="2" /> 
     
    <telerik:RadInputManager ID="RadInputManager1" runat="server" Skin="Vista"
        <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting1" InitializeOnClient="true"
            <TargetControls> 
                <telerik:TargetInput ControlID="TextBox1" /> 
            </TargetControls> 
        </telerik:NumericTextBoxSetting> 
        <telerik:DateInputSetting BehaviorID="DateInputSetting1" InitializeOnClient="true"
            <TargetControls> 
                <telerik:TargetInput ControlID="TextBox2" /> 
            </TargetControls> 
        </telerik:DateInputSetting> 
    </telerik:RadInputManager> 
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
    <script type="text/javascript"
     
    function associate() 
        var im = $find("<%= RadInputManager1.ClientID %>"); 
         
        var numericSetting = im.get_inputSettings("NumericTextBoxSetting1"); 
        numericSetting.addTargetInput("<%= TextBox3.ClientID %>"); 
     
        var dateSetting = im.get_inputSettings("DateInputSetting1"); 
        dateSetting.addTargetInput("<%= TextBox4.ClientID %>"); 
         
        return false; 
     
    </script> 
    </telerik:RadCodeBlock> 
     
    </form> 
    </body> 
    </html> 


    All the best,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 01 Jun 2009 Link to this post

    My problem was that I was setting the Visibility of my text box to false!
    If I want to hide the text box just to use a dummy control for the input manager, I should be setting its display style to none.

    Thanks.
  5. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 01 Jun 2009 Link to this post

    Hey, While I'm here I may as well put this one out there.

    If I have the text box formatting the value for me, how do i get the raw value out of it excluding the formatting?
    If a user types 1000, the text box formats it as 1,000. For calculations I'd like the value without commas. If there's a way to do that using jquery that would be helpful.

    $('input.RadInputMgr_Vista', selectedItems[i].get_element()).val(); This returns the value with formatting.

    thanks
  6. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 02 Jun 2009 Link to this post

    Hello Matt,

    If you use the RadInputManager API and the get_value() method, you will get the real numeric value, instead of the formatted one that you are seeing in the textbox.

    var im = $find("<%= RadInputManager1.ClientID %>");
    var v = im.get_targetInput("<%= TextBox1.ClientID %>").get_value();


    Kind regards,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 02 Jun 2009 Link to this post

    Thanks a lot, Dimo.

    There's still another issue I've been meaning to mention.
    So what I'm doing, as I tried to previously illustrate, is grabbing a bunch if input items using jquery and then loading those into a radInputManager. All these inputs are rendered in a radGrid using a column renderer all on the client-side.
    A numeric input gets a numeric class so I can therefore grab all my numeric inputs using the line

    var elements = $('input.numeric'); 

    I then generate a unique Id for each of the inputs before loading them into the numeric settings of my input manager

                var numericSettings = $find('RadInputManager').get_inputSettings('NumericSettings'); 
                Array.forEach(elements, function(element) { 
                    numericSettings.addTargetInput(element.id); 
                });   

    After I load my elements into the manager, the class is completely overwritten by RadInputMgr_Vista. Is this behaviour by design? I'd rather it append to any existing class so I don't lose the ability to grab all my numeric inputs.

    I was thinking, immediately after loading my inputs into the manager, to do something like this to re-add my desired class
    $("input.RadInputMgr_Vista").addClass("numeric"); //since adding controls to the manager collection overwrites existing classes, readding them here. 

     But that won't help me if after dealing with my numeric inputs I have to do the same work on my ascii ones.
     //get all ascii data format text boxes and convert them into text 
                elements = $('input.ascii'); 
              
                var textSettings = $find('RadInputManager').get_inputSettings('TextSettings'); 
                Array.forEach(elements, function(element) { 
                    textSettings.addTargetInput(element.id); 
                });                 
                $("input.RadInputMgr_Vista").addClass("ascii"); //since adding controls to the manager collection overwrites existing classes, readding them here. 

    At the end there, all of my RadInputMgr_Vista inputs, including my numeric ones, will also get the ascii class...

    Any thoughts?

    Thanks.

  8. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 05 Jun 2009 Link to this post

    Hello Matt,

    Yes, RadInputManager currently overwrites the existing CSS classes of textboxes. We may change that in the future. Currently you have two options to grab all RadInputManager textboxes:

    1) add your custom CSS class to the InputManager settings, so that you can get all textboxes with jQuery:

    <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting1"
            InitializeOnClient="true" EnabledCssClass="numeric">

    (this will append the CSS class to the control's default ones)


    2) Iterate through all textboxes by using the InputManager's API, e.g. :

    input_manager_instance.get_numericTextBoxSettings()[0].get_targetControlIDs()



    Regards,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 05 Jun 2009 Link to this post

    Very nice. I like option 1. Thanks.
  10. Scott R
    Scott R avatar
    63 posts
    Member since:
    Jun 2008

    Posted 01 Dec 2009 Link to this post

    Grrrr!

    Why does the RadInputManager even need a "dummy control"? And, why don't the docs mention this?

    Thanks for the thread, towps.
  11. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 04 Dec 2009 Link to this post

    Hello,

    Indeed, this limitation exists by design. We will research for ways to remove it in future versions and will mention it in the documentation. Thanks.

    Regards,
    Dimo
    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.
  12. Shawn
    Shawn avatar
    83 posts
    Member since:
    Jan 2009

    Posted 02 Mar 2010 Link to this post

    Dimo,

    Given your example here:  how can I toggle on and off an entire inputManager?  I am showing/hiding textboxes based on user input, but I want to be able to validate all shown controls on submit.  So if a user changes a dropdown I need the new boxes to be validated, if they change again then they will be hidden and not validated.

    It seems to make sense to me to just break them all into separate inputmanagers and then enable/disable them. But can this be done on the client?
  13. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 04 Mar 2010 Link to this post

    Discussion about RadInputManager enable/disable continues at:

    http://www.telerik.com/community/forums/aspnet-ajax/ajax/ajax-and-inputmanager-issues.aspx

    Please try not to post the same question in several forum threads.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017