RadListView findcontrol Javascript

2 posts, 0 answers
  1. Adam
    Adam avatar
    3 posts
    Member since:
    Jan 2011

    Posted 20 Dec 2011 Link to this post

    I have RadEditor and a Table within a RadListView.
    When someone clicks on one of the cells in the Table, I want to paste text from the cell into the RadEditor.
    I have the functionality working when the RadEditor is not within a RadListView, but I am not sure how to make it work within the RadListView.

    Here is the code for the RadEditor when it is not in the RadListView -

                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                <script type="text/javascript">
                                    $(document).ready(function ()
                                        $('.clickMe').each(function ()
                                            $(this).attr("unselectable", "on");
                                            $(this).click(function ()
                                                var editor = $find("<%=reKeyLink.ClientID%>");
                            <div style="clear: left; margin-top: 15px; width:825px">
                                <div style="float:left;">
                                    <telerik:RadEditor ID="reKeyLink" runat="server" Skin="Windows7" ViewStateMode="Disabled"
                                        ToolsFile="~/App_Themes/public/ToolsLimited.xml" Height="235px" Width="625px">
                                <div class="Tokens" id="overlay" style="float:left; visibility:hidden; border: 1px solid #A5B3C5; width:185px; text-align:center; margin-left:10px;">
                                    <table id="tableid">
                                        <tr style="width:184px">
                                            <td class="clickMe" style=" text-align:right; width:92px">{ACCOUNT_ID}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{ADDR_LINE1}</td>
                                            <td class="clickMe" style=" text-align:right">{ADDR_LINE2}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{CITY}</td>
                                            <td class="clickMe" style=" text-align:right">{COMPANY}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{EMAIL_ADDR}</td>
                                            <td class="clickMe" style=" text-align:right">{FIRST_NAME}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{LAST_LOGIN}</td>
                                            <td class="clickMe" style=" text-align:right">{LAST_NAME}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{LOCATION}</td>
                                            <td class="clickMe" style=" text-align:right">{MIDDLE_INIT}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{NICKNAME}</td>
                                            <td class="clickMe" style=" text-align:right">{POS_CUST_ID}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{PREFIX_NAME}</td>
                                            <td class="clickMe" style=" text-align:right">{REVIEWER_ID}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{STATE}</td>
                                            <td class="clickMe" style=" text-align:right">{SUFFIX_NAME}</td><td style="width:5px"></td><td class="clickMe" style=" text-align:left">{ZIPCODE}</td>
                                <div style="clear: left;">
                                    <asp:RequiredFieldValidator ID="rfvKeyLink" runat="server" ControlToValidate="reKeyLink"
                                        ValidationGroup="AddKeyLink" Display="Dynamic" Text="Key link text is required." />

    I wish to make the code above to work in a RadListView defined like so -
                    <telerik:RadListView runat="server" ID="rlvKeyLinks" Skin="Windows7" EnableEmbeddedSkins="true"
                        RegisterWithScriptManager="true" AllowMultiItemEdit="false" OnNeedDataSource="RlvKeyLinks_NeedDataSource"
                        OnItemCommand="RlvKeyLinks_ItemCommand" OnItemCreated="RlvKeyLinks_ItemCreated"
                        AllowCustomPaging="true" AllowPaging="true" ItemPlaceholderID="phKeyLinksView"
    -------------RadEditor and Table here--------------

    Can you help?

  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 23 Dec 2011 Link to this post

    Hello Adam,

    Try the following:
    Add a runat="server" to the table, so that it can get a full ID genereated. Then, when a click event occurs, use the parentNode attribute to go from the cell to the table itself. Take the table id attribute, replace "tableid" with "reKeyLink" inside this id string and use it with $find to find the editor:
    var editorId = table.id.replace('tableId','reKeyLink'); //where table is the <table> dom element
    var editor = $find(editorId);

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top