LinkButton within

2 posts, 0 answers
  1. George
    George avatar
    3 posts
    Member since:
    Jan 2013

    Posted 27 Jan 2013 Link to this post

    Hi, I have a RadGrid within a RadAjaxPanel. One of the columns has a LinkButton whose click javascript is set when the Item is created to call another Javascript method, "ShowExisting3" with the index corresponding to the DataRow. When ShowExisting3 is called, the javascript method doesn't have access to any controls other than the ajax manager and script manager (as in, all calls like $find("<%= flightConfigGrid.ClientID %>") return null).

    I've also tried setting the onclick javascript to directly call ShowExisting3(0) and $find still returns null. Strangely enough, oWnd in both cases is not null. What I can't figure out is why configValuesWindow can be accessed and flightConfigGrid cannot. My end goal is a popup window (configValuesWindow) whose contents are populated by 2 invisible columns in the data grid. Does anyone have any ideas?

    Here's much of the aspx, and afterwards some of the C#
    <telerik:RadScriptManager ID="scriptManager" runat="server" />
    <telerik:RadAjaxManager ID="ajaxManager" runat="server" OnAjaxRequest="ajaxManager_AjaxRequest">
    <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="ajaxManager">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="inputPanel" />
    <telerik:AjaxUpdatedControl ControlID="errorPanel" />
    <telerik:AjaxUpdatedControl ControlID="configPanel" LoadingPanelID="ajaxLoadingPanel" />
    <telerik:AjaxUpdatedControl ControlID="mappingsPanel" />
    <telerik:AjaxUpdatedControl ControlID="rotationsPanel" />
    <telerik:AjaxUpdatedControl ControlID="featureCompositionPanel" />
    <telerik:AjaxUpdatedControl ControlID="permaLinkPanel" />
    </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="TopSubmitButton">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="inputPanel" />
    <telerik:AjaxUpdatedControl ControlID="errorPanel" />
    <telerik:AjaxUpdatedControl ControlID="configPanel" LoadingPanelID="ajaxLoadingPanel" />
    <telerik:AjaxUpdatedControl ControlID="mappingsPanel" />
    <telerik:AjaxUpdatedControl ControlID="rotationsPanel" />
    <telerik:AjaxUpdatedControl ControlID="featureCompositionPanel" />
    <telerik:AjaxUpdatedControl ControlID="permaLinkPanel" />
    </UpdatedControls>
    </telerik:AjaxSetting>
    <telerik:AjaxSetting AjaxControlID="configPanel">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="configValuesWindowPanel" />
    </UpdatedControls>
    </telerik:AjaxSetting>
    </AjaxSettings>
    <ClientEvents OnRequestStart="RequestStart" OnResponseEnd="ResponseEnd" />
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="ajaxLoadingPanel" runat="server" Skin="Default"/>
    <telerik:RadWindowManager ID="windowManager" runat="server" />
    <telerik:RadWindow runat="server" ID="configValuesWindow" VisibleStatusbar="False" VisibleTitlebar="True" AutoSize="True" MinWidth="400">
    <ContentTemplate>
    <asp:UpdatePanel ID="configValuesWindowPanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <table width="100%">
    <tr>
    <td width="50%"><b>Values in Flight</b></td>
    <td width="50%"><b>Values out of Flight</b></td>
    </tr>
    <tr style="vertical-align: top">
    <td id="ValuesInFlightCell">
    <asp:Label ID="FooBaz" runat="server"></asp:Label>
    </td>
    <td id="ValuesOutOfFlightCell" />
    </tr>
    </table>
    </ContentTemplate>
    </asp:UpdatePanel>
    </ContentTemplate>
    </telerik:RadWindow>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
    function RequestStart(sender, args) {
    var loadingPanel = $find("<%= ajaxLoadingPanel.ClientID %>");
    var updatedControl = "<%= configPanel.ClientID %>";
    //show the loading panel over the updated control
    loadingPanel.show(updatedControl);
    }
    function ResponseEnd() {
    var loadingPanel = $find("<%= ajaxLoadingPanel.ClientID %>");
    var updatedControl = "<%= configPanel.ClientID %>";
    if (loadingPanel != null) {
    loadingPanel.hide(updatedControl);
    }
    }
    function pageLoad(sender, eventArgs) {
    if (!eventArgs.get_isPartialLoad()) {
    $find("<%= ajaxManager.ClientID %>").ajaxRequest("InitialPageLoad");
    }
    }
    function ShowExisting3(index) {
    var oWnd = $find("<%= configValuesWindow.ClientID %>");
    var dataItem = $find("<%= flightConfigGrid.ClientID %>").get_masterTableView().get_dataItems()[index];
    var inValues = dataItem.getDataKeyValue("InParams");
    var outValues = dataItem.getDataKeyValue("OutParams");
    document.getElementById('ValuesInFlightCell').innerHTML = inValues;
    document.getElementById('ValuesOutOfFlightCell').innerHTML = outValues;
    oWnd.show();
    }
    </script>
    </telerik:RadCodeBlock>
    <h2><asp:Literal ID="PageTitleLiteral" runat="server" Text="Single Flight Config"></asp:Literal></h2>
    <telerik:RadAjaxPanel ID="inputPanel" runat="server">
    <asp:Literal ID="FlightNameLiteral" runat="server" Text="Flight:" />
    <asp:TextBox ID="FlightNameTextBox" runat="server"></asp:TextBox>
    <asp:Button ID="TopSubmitButton" runat="server" Text="Submit" onclick="TopSubmitButton_Click" />
    <asp:Literal ID="UIMessageLiteral" runat="server" Text=""></asp:Literal>
    </telerik:RadAjaxPanel>
    <br />
    <telerik:RadAjaxPanel ID="errorPanel" runat="server" CssClass="error">
    <br />
    <asp:Literal ID="errorLiteral" runat="server" />
    </telerik:RadAjaxPanel>
    <br />
    <telerik:RadAjaxPanel ID="configPanel" runat="server" ScrollBars="Auto" Width="100%">
    <telerik:RadGrid ID="flightConfigGrid" runat="server" AutoGenerateColumns="False"
    AllowSorting="True" GridLines="None" AllowPaging="True" PageSize="100"
    OnItemCreated="OnItemCreated" OnDataBound="OnDataBound" OnItemCommand="OnItemCommand">
    <MasterTableView DataKeyNames="Path" AllowMultiColumnSorting="True" SortExpressions="Environment"
    GroupLoadMode="Server">
    <Columns>
    <telerik:GridBoundColumn DataField="Environment" HeaderText="Environment"
    SortExpression="Environment" />
    <telerik:GridBoundColumn DataField="Path" HeaderText="Path"
    SortExpression="Path" />
    <telerik:GridBoundColumn DataField="FileName" HeaderText="FileName"
    SortExpression="FileName" />
    <telerik:GridBoundColumn DataField="SectionName" HeaderText="Section"
    SortExpression="SectionName" />
    <telerik:GridBoundColumn DataField="ParameterName" HeaderText="Parameter"
    SortExpression="ParameterName" />
    <telerik:GridBoundColumn DataField="AdditionalFilterSetName"
    HeaderText="Additional Filters" SortExpression="AdditionalFilterSetName" />
    <telerik:GridTemplateColumn UniqueName="InParamWithMouseOver" HeaderText="Values in Flight (click for full set)">
    <ItemTemplate>
    <%# Eval("InParameterValue") %>
    <asp:LinkButton ID="InParamLink" runat="server" CommandName="InParamLink" Text="..."/>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="InParams" HeaderText="InParams" Visible="False"/>
    <telerik:GridTemplateColumn UniqueName="OutParamWithMouseOver" HeaderText="Values Outside of Flight (click for full set)">
    <ItemTemplate>
    <%# Eval("OutParameterValue") %>
    <asp:LinkButton ID="OutParamLink" runat="server" CommandName="OutParamLink" Text="..."/>
    </ItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridBoundColumn DataField="OutParams" HeaderText="InParams" Visible="False"/>
    </Columns>
    </MasterTableView>
    </telerik:RadGrid>
    </telerik:RadAjaxPanel>

    Here is the C# for the DataBound event. It sets the onclick event to call ShowExisting3(index) which exists already in the aspx. When it is called, the $find methods return null.
    protected void OnDataBound(object sender, EventArgs e)
    {
    foreach (GridDataItem item in this.flightConfigGrid.Items)
    {
    var inParamsLinkCell = item["InParamWithMouseOver"];
    var inParamsCell = item["InParams"];
    var inParamLinkControl = (LinkButton)inParamsLinkCell.FindControl("InParamLink");
    inParamLinkControl.Attributes.Add(
    "onclick",
    string.Format("ShowExisting3({0});return false;", item.ItemIndex));
    }
    }

    Thanks!
  2. Eyup
    Admin
    Eyup avatar
    3796 posts

    Posted 30 Jan 2013 Link to this post

    Hi George,

    I have already replied to your query in the following forum thread:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/linkbutton-within-radgrid-can-t-update-other-panels.aspx

    I suggest that we continue our conversation on the mentioned thread to enable other users with similar issues to track  the discussion more easily. In addition, please note that avoiding multiple threads with similar issues will enable us to respond more quickly and efficiently to your posts.

    All the best,
    Eyup
    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