Question

Hey guys I am having a tough one. I have a radgrid that contains a list of checkboxes. Now when the user changes the check box the checkbox does a postback and changes the text and color of the row. Now when it does this it yanks the focus to that row. So if I check the box and scroll up to the top of the page it will yank me back to the bottom. I would like to make it so it doesn't change any focus and just does an async postback.

Here is just the checkbox pulled from the grid

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

Now here is the whole grid with the checkbox code inside. Again I just want to stop the focus change. I want the user to be able to uncheck a box and scroll without worrying about their focus yanking back to the row they changed.

    <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>

I greatly appreciate any help you guys can provide on this one.

Was it helpful?

Solution

I found the answer here

<script type="text/javascript">

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

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top