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

set radtextbox text property on client(JavaScript)

5 Answers 620 Views
Input
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 25 Apr 2011, 02:45 PM
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.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Apr 2011, 05:15 AM
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
0
Ron
Top achievements
Rank 1
answered on 26 Apr 2011, 12:44 PM
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>
0
Shinu
Top achievements
Rank 2
answered on 27 Apr 2011, 12:06 PM
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.
0
Ron
Top achievements
Rank 1
answered on 27 Apr 2011, 12:21 PM
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,
0
Ron
Top achievements
Rank 1
answered on 27 Apr 2011, 12:41 PM
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.
Tags
Input
Asked by
Ron
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Ron
Top achievements
Rank 1
Share this question
or