set radtextbox text property on client(JavaScript)

6 posts, 0 answers
  1. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 25 Apr 2011 Link to this post

    Hi,

    Can somebody help me set text box property on the client. The problem I'm having is that the text box is within the rad grid control.
    I'm able to set the textbox text property with the following but not when the textbox is in telerik:GridTemplateColumn.

            var textbox =  $find("txtDescription");
      textbox .set_value(result);

    but this doesn't work for the following.

      <telerik:GridTemplateColumn HeaderText="Description" DataField="Description"  UniqueName="Description">
                            <EditItemTemplate>
                                 <telerik:RadTextBox ID="txtDescription" runat="server" Width="200px"> </telerik:RadTextBox>
                            </EditItemTemplate>
    </telerik:GridTemplateColumn>

    Thanks,
    Ron.

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

    Posted 26 Apr 2011 Link to this post

    Hello Ron,

    Please take a look at the Accessing server controls in a grid template on the client code library to see how the desired functionality can be implemented.

    I hope this helps.

    Thanks,
    Shinu
  3. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 26 Apr 2011 Link to this post

    I really appreciate your help Shinu,

    However I'm still having trouble. When I use GetRegisteredServerElement() it returns "object HTMLInputElement".
    But if i replace "return document.getElementById(clientID);" with "return clientID" i get the clientId of the server textbox which I want, but I have multiple row's in that grid and it's only returning the Id for the last row. How can I get the I'd for a particular row? Here's my code. Any suggestions?

    function GetRegisteredServerElement(serverID) {
                var clientID = "";
                for (var i = 0; i < registeredElements.length; i++) {
                    clientID = registeredElements[i];
                    if (clientID.indexOf(serverID) >= 0)
                        break;
                }
                return clientID;
            }

    <telerik:GridTemplateColumn HeaderText="Description" DataField="Description"  UniqueName="Description">
                           <EditItemTemplate>
                               <%--<asp:TextBox ID="txtDescription" runat="server" Width="200px"></asp:TextBox>--%>
                           <telerik:RadTextBox ID="txtDescription" runat="server" Width="200px"> </telerik:RadTextBox>
                           <script type="text/javascript">
                               registeredElements.push('<%# Container.FindControl("txtDescription").ClientID %>'); 
                           </script>
                           </EditItemTemplate>
                       </telerik:GridTemplateColumn>
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2011 Link to this post

    Hello Ron,

    Since you are using RadTextBox one easy approach is to attach the ClientEvents-OnLoad, which is called when the input control is loaded on the client and then save the object in a global variable. Now you can access it from any client side function.

    aspx:
    <EditItemTemplate
       <telerik:RadTextBox ID="txtDescription"  ClientEvents-OnLoad="OnLoad" runat="server" > </telerik:RadTextBox>                   
     </EditItemTemplate>

    Javascript:
    <script type="text/javascript">
       var txtBox;
        function OnLoad(Sender)
        {
            txtBox=Sender;
        }
    </script>

    Thanks,
    Shinu.
  5. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 27 Apr 2011 Link to this post

    Once again I really appreciate your help, but I don't understand how this help's. The problem I'm having right now is setting the textbox value based on row. Is there a way i can set the textbox based on row i.e rowId.textbox = "value"? Here's what I'm trying to  do, I have a rad grid with 5 columns and multiple rows. The first column is a combo which allows the user to select a value, based on that value ,on selected index changed I want to set the corresponding column textboxs for that row. And right now I have no way to specify which row get's the value. When i call the textbox client id, its gives me the same clientid everytime, no matter which row I'm editing. Please see attached screen shot to get a better idea.

    Thanks,
  6. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 27 Apr 2011 Link to this post

    I've implemented your last example and again it return's the client textbox id for the last row, which is row 3. I need a way to get the clientid for the row which is being edited.
Back to Top