动态发生回发时如何设置选项卡索引radmultipage?

发布于 2024-12-02 09:36:00 字数 2038 浏览 1 评论 0原文

代码

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" OnTabClick="RadTabScript1_TabClick" OnClientTabSelecting="onTabSelecting" >  <%-- OnClientTabSelecting="onTabSelecting"> --%>
    <Tabs>
        <telerik:RadTab Text="Resources" runat="server" TabIndex="0" Selected="true" PageViewID="radPageResources"></telerik:RadTab>
        <telerik:RadTab Text="Tasks" runat="server" TabIndex="1" PageViewID="radPageTasks"></telerik:RadTab>
        <telerik:RadTab Text="Messages" runat="server" TabIndex="2" PageViewID="radPageMessages"></telerik:RadTab>
        <telerik:RadTab Text="Files" runat="server" TabIndex="3" PageViewID="radPageFiles"></telerik:RadTab>
        <telerik:RadTab Text="Feedback" runat="server" TabIndex="4" PageViewID="radPageFeedback"></telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated" SelectedIndex="0" >  <%--  RenderSelectedPageOnly="true"  >  --%>
<telerik:RadPageView ID="radPageResources" runat="server" TabIndex="0">
<telerik:RadGrid runat="server" ID="grdResource" PageSize="5" Skin="Default" AllowPaging="True"
    AllowSorting="true" ShowFooter="true" AutoGenerateColumns="False" Width="97%"
    OnItemCreated="grdResource_ItemCreated" OnNeedDataSource="grdResource_NeedDataSource"
    OnDeleteCommand="grdResource_DeleteCommand" ShowStatusBar="True" GridLines="None"
    OnItemDataBound="grdResource_ItemDataBound">
</telerik:RadGrid>

像这样,我有 4 个带有索引的综合浏览选项卡,每个综合浏览选项卡都包含一个网格。如果假设我在某些 x 网格中进行了更改并导致回发,那么我需要在之后显示 x 网格回发。但我正在显示资源网格。

代码隐藏

protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{ 
    RadMultiPage1.SelectedIndex = e.PageView.TabIndex;
}

但该事件在任何情况下都不会触发。
那么即使发生回发,我怎样才能回到之前的网格呢?

Code

<telerik:RadTabStrip ID="RadTabStrip1" runat="server" MultiPageID="RadMultiPage1" OnTabClick="RadTabScript1_TabClick" OnClientTabSelecting="onTabSelecting" >  <%-- OnClientTabSelecting="onTabSelecting"> --%>
    <Tabs>
        <telerik:RadTab Text="Resources" runat="server" TabIndex="0" Selected="true" PageViewID="radPageResources"></telerik:RadTab>
        <telerik:RadTab Text="Tasks" runat="server" TabIndex="1" PageViewID="radPageTasks"></telerik:RadTab>
        <telerik:RadTab Text="Messages" runat="server" TabIndex="2" PageViewID="radPageMessages"></telerik:RadTab>
        <telerik:RadTab Text="Files" runat="server" TabIndex="3" PageViewID="radPageFiles"></telerik:RadTab>
        <telerik:RadTab Text="Feedback" runat="server" TabIndex="4" PageViewID="radPageFeedback"></telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage ID="RadMultiPage1" runat="server" OnPageViewCreated="RadMultiPage1_PageViewCreated" SelectedIndex="0" >  <%--  RenderSelectedPageOnly="true"  >  --%>
<telerik:RadPageView ID="radPageResources" runat="server" TabIndex="0">
<telerik:RadGrid runat="server" ID="grdResource" PageSize="5" Skin="Default" AllowPaging="True"
    AllowSorting="true" ShowFooter="true" AutoGenerateColumns="False" Width="97%"
    OnItemCreated="grdResource_ItemCreated" OnNeedDataSource="grdResource_NeedDataSource"
    OnDeleteCommand="grdResource_DeleteCommand" ShowStatusBar="True" GridLines="None"
    OnItemDataBound="grdResource_ItemDataBound">
</telerik:RadGrid>

Like this i have 4 pageview tabs with indexes and every pageview tab contains a grid.If suppose i did changes in some x-grid and causes postback,then i need the x-grid should be shown after the postback. But i was showing the Resourcegrid.

codebehind

protected void RadMultiPage1_PageViewCreated(object sender, RadMultiPageEventArgs e)
{ 
    RadMultiPage1.SelectedIndex = e.PageView.TabIndex;
}

but this event not firing in any case.
so how can i come back to the previous grid even when postback occurs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆悲凉 2024-12-09 09:36:00

尝试在 page_prerender 中设置选定的索引。

protected void Page_PreRender(object sender, EventArgs e)
{

        //RadTab t1 = new RadTab();
        //RadMultiPage m1 = new RadMultiPage();
        m1.SelectedIndex = t1.SelectedIndex;
}

try set selected index in page_prerender.

protected void Page_PreRender(object sender, EventArgs e)
{

        //RadTab t1 = new RadTab();
        //RadMultiPage m1 = new RadMultiPage();
        m1.SelectedIndex = t1.SelectedIndex;
}
一身骄傲 2024-12-09 09:36:00

我不知道我的解决方案对这个主题是否有帮助
我尝试了所有方法,终于找到了自己的方法,

我建议如果您的问题没有解决,请制作java脚本函数,然后从代码后面调用它
我的示例:

   function OnClientClick1(i) {

        var tabstrip1 = $find("<%=RadTabStrip1.ClientID %>");

            tabstrip1.set_selectedIndex(1);

    }

然后在您的代码上创建函数来调用

 private void ChangeTab(int index)
    {
        string scriptyKey = "Alert" + Guid.NewGuid().ToString().Replace("-", "_");
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptyKey, "OnClientClick1("+index.ToString()+");", true);

    }

我希望有用的功能

i don't know my solution can be helpful for this subject or not
I tried all methods and finally find myself method,

i suggest if your problem not solved make java script function and then call it from code behind
My Sample :

   function OnClientClick1(i) {

        var tabstrip1 = $find("<%=RadTabStrip1.ClientID %>");

            tabstrip1.set_selectedIndex(1);

    }

and then make function on your code to call that

 private void ChangeTab(int index)
    {
        string scriptyKey = "Alert" + Guid.NewGuid().ToString().Replace("-", "_");
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptyKey, "OnClientClick1("+index.ToString()+");", true);

    }

I hope be useful

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文