停止autopostback上的焦点更改= true

时间:2013-08-21 17:00:20

标签: asp.net checkbox telerik postback radgrid

嘿,伙计们我很难受。我有一个包含复选框列表的radgrid。现在,当用户更改复选框时,复选框会执行回发并更改行的文本和颜色。现在,当它这样做时,它将焦点拉到那一行。因此,如果我选中该框并向上滚动到页面顶部,它会将我拉回到底部。我想这样做它不会改变任何焦点,只是做一个异步回发。

这是从网格中拉出的复选框

 <asp:CheckBox runat="server" ID="isChecked" Checked='<%# Eval("active") %>' AutoPostBack="true"
                                          OnCheckedChanged="CheckChanged" ToolTip="Activate/In-activate relationship between Event and Category" />

现在这里是整个网格,里面有复选框代码。我只是想停止焦点改变。我希望用户能够取消选中一个框并滚动,而不必担心他们的焦点会回到他们改变的行。

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True"
                     CssClass="mdmGrid active" CellSpacing="0" DataSourceID="eventsINcategories" GridLines="None"
                     Width="80%" OnItemDataBound="RadGrid1_ItemDataBound">
        <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
            <Selecting AllowRowSelect="True" />
        </ClientSettings>
        <MasterTableView AutoGenerateColumns="False" DataSourceID="eventsINcategories">
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
            </RowIndicatorColumn>
            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridTemplateColumn UniqueName="ActiveDisabled" HeaderText="Status" AllowFiltering="false">
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="isChecked" Checked='<%# Eval("active") %>' AutoPostBack="true"
                                      OnCheckedChanged="CheckChanged" ToolTip="Activate/In-activate relationship between Event and Category" />
                        <asp:Label ID="Label2" runat="server" ForeColor='<%# (bool)Eval("active") ? System.Drawing.Color.Green : System.Drawing.Color.Red %>'
                                   Text='<%# string.Format("{0}", (bool)Eval("active") ? "Active" : "In-Active") %>'></asp:Label>
                        <asp:Label runat="server" ID="hidd_CategoryID" Text='<%# Eval("categoryID") %>' Style="display: none; color:Red;"></asp:Label>
                        <asp:Label runat="server" ID="hidd_eventID" Text='<%# Eval("eventID") %>' Style="display: none;"></asp:Label>
                        <asp:Label runat="server" ID="hide_EventActivation" Text='<%# DataBinder.Eval(Container.DataItem, "eventActivation") %>' Visible="false"></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="100px" />
                </telerik:GridTemplateColumn>
                <telerik:GridBoundColumn DataField="eventDetail" FilterControlAltText="Filter eventDetail column"
                                         HeaderText="Event and Event Codes" ReadOnly="True" SortExpression="eventDetail"
                                         UniqueName="eventDetail">
                    <ItemStyle Width="200px" />
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="categoryName" FilterControlAltText="Filter categoryName column"
                                         HeaderText="Category" SortExpression="categoryName" UniqueName="categoryName">
                    <ItemStyle Width="100px" />
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn UniqueName="NotifyOptions" HeaderText="Notify Options" AllowFiltering="true" SortExpression="NotifyOptions">
                    <ItemTemplate>
                        <asp:Label ID="notifyOptionsText" runat="server" Text=""></asp:Label>
                        <asp:Label runat="server" ID="notifyEmail" Text='<%# DataBinder.Eval(Container.DataItem, "notifyEmail") %>' Visible="false"></asp:Label>
                        <asp:Label runat="server" ID="notifyTextMessage" Text='<%# DataBinder.Eval(Container.DataItem, "notifyTextMessage") %>' Visible="false"></asp:Label>
                    </ItemTemplate>
                    <ItemStyle Width="100px" />
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
            <BatchEditingSettings EditType="Cell" />
            <PagerStyle PageSizeControlType="RadComboBox" AlwaysVisible="true"></PagerStyle>
        </MasterTableView>
        <PagerStyle PageSizeControlType="RadComboBox" />
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
    </telerik:RadGrid>

我非常感谢你们在这个方面提供的任何帮助。

1 个答案:

答案 0 :(得分:0)

我找到了答案here

<script type="text/javascript">

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_beginRequest(function() {
    prm._scrollPosition = null;
});