简体   繁体   English

Telerik radgrid与Hierarchy不在OnHierarchyExpanding事件上运行客户端javascript

[英]Telerik radgrid with Hierarchy doesn't run client javascript on OnHierarchyExpanding event

I have a javascript, that I need to be run on expand link click 我有一个JavaScript,需要在扩展链接上运行

 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function RowExpanded(sender, eventArgs) {
                    alert(123);
                }
            </script>
 </telerik:RadCodeBlock>

I use HierarchyLoadMode="Conditional" for inner grid data load on my aspx page. 我使用HierarchyLoadMode =“ Conditional”在aspx页面上加载内部网格数据。

<telerik:RadAjaxPanel runat="server">
            <telerik:RadGrid ID="rgUsersInSessions" ShowStatusBar="true" OnNeedDataSource="OnNeedDataSourceForGrid" OnDetailTableDataBind="OnDetailTableDateBind" OnItemDataBound="OnAnswerItemBound" runat="server" AutoGenerateColumns="False" PageSize="10"
                AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True" GridLines="None">
                <ClientSettings AllowExpandCollapse="True">
                    <Selecting AllowRowSelect="True"></Selecting>
                    <ClientEvents OnHierarchyExpanding="RowExpanded" />
                </ClientSettings>
                <PagerStyle Mode="NumericPages"></PagerStyle>
                <MasterTableView EnableHierarchyExpandAll="true" AllowMultiColumnSorting="True" ClientIDMode="Static" HierarchyLoadMode="Conditional">
                    <DetailTables>
                        <telerik:GridTableView HierarchyLoadMode="Conditional" EnableHierarchyExpandAll="true" Width="100%" runat="server" ClientIDMode="Static" ShowHeader="False">
                                <Columns>
                                <telerik:GridTemplateColumn UniqueName="userQuestion">
                                    <ItemTemplate>
                                        <asp:Label  Text='<%# DataBinder.Eval(Container.DataItem, "EventId").ToString() %>'></asp:Label>                                     
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                        </telerik:GridTableView>
                        </DetailTables>
                    <Columns>  
                        <telerik:GridBoundColumn UniqueName="SessionUserId" Display="False" AllowFiltering="false" DataField="SessionUserId" DataType="System.Int32">
                        </telerik:GridBoundColumn>
                     </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

When I click the expand link at the grid, it expands inner table and load the table date in it, but my javascript function (RowExpanded) wasn't run. 当我单击网格上的扩展链接时,它会扩展内部表格并在其中加载表格日期,但是我的JavaScript函数(RowExpanded)没有运行。 On page load I can find the the function on the page, but after clicking the expand link I can't see it anymore. 在页面加载时,我可以在页面上找到该函数,但是单击展开链接后,我将不再看到它。

Knowing how some of those features are only available when binding via the client, I'm assuming that method isn't running because you aren't using the JavaScript API. 知道其中某些功能仅在通过客户端绑定时才可用,因此我假设该方法未运行,因为您未使用JavaScript API。 Certain things only work if you are using that API. 某些事情仅在使用该API时有效。

You say you can't see the method anymore. 您说您看不到该方法了。 Depending on how you are inspecting the page, it could be the tool you are using doing that (I know when working with ajax panels, it changes the viewable response output in tools like Firebug, etc.). 根据您检查页面的方式,它可能是您正在使用的工具(我知道使用ajax面板时,它会更改Firebug等工具中的可见响应输出)。

Found the problem by myself. 自己发现问题。

I set ClientIDMode="Static" at 我将ClientIDMode =“ Static”设置为

<MasterTableView EnableHierarchyExpandAll="true" AllowMultiColumnSorting="True" ClientIDMode="Static" HierarchyLoadMode="Conditional">

and at

<telerik:GridTableView HierarchyLoadMode="Conditional" EnableHierarchyExpandAll="true" Width="100%" runat="server" ClientIDMode="Static" ShowHeader="False">

But this elements have no setter for ID. 但是,此元素没有ID的设置方法。 It generates onClick javascript where 它生成onClick javascript,其中

$find("") returns null. $find("")返回null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM