Setting focus on page after insert

2 posts, 0 answers
  1. Alexandru
    Alexandru avatar
    5 posts
    Member since:
    Jun 2015

    Posted 08 Jul 2015 Link to this post

    I have the following Radgrid control with AllowPaging = true. The Items in the Radgrid are sorted in decreasing order after the date in the second column. After I insert a row, I want the focus to be set on the page where the item was inserted. I have tried the following code in the Insert_Command event:

    <telerik:RadGrid ID="rgCondica"
                PageSize="5" PagerStyle-ShowPagerText="False"
                PagerStyle-AlwaysVisible="true" MasterTableView-NoMasterRecordsText="Nu exista inregistrari" PagerStyle-FirstPageToolTip="Prima pagina"
                PagerStyle-LastPageToolTip="Ultima pagina" PagerStyle-PageSizeLabelText="Nr. inregistrari:" PagerStyle-PrevPagesToolTip="Paginile anterioare"
                PagerStyle-PrevPageToolTip="Pagina anterioara" PagerStyle-NextPagesToolTip="Paginile urmatoare" PagerStyle-NextPageToolTip="Pagina anterioara">
    protected void rgCondica_InsertCommand(object sender,GridCommandEventArgs e){
    GridDataItem item = rgCondica.MasterTableView.FindItemByKeyValue("IdCondica", c.IdCondica);
     rgCondica.CurrentPageIndex = item.RowIndex;

    but it remains on the last page.


    Any help is appreciated. Thank you.

  2. Eyup
    Eyup avatar
    3940 posts

    Posted 13 Jul 2015 Link to this post

    Hello Alexandru,

    This requirement may be somewhat tricky. You will need to find a way to determine the page and the position of the given record from the query string. Using the unique DataKeyValue of the item you can access the database position of the record by initiating some server-side query operation depending on your datasource type. Then, you can make some calculations to determine on which page the record is located on and go to that page using the CurrentPageIndex property. For instance, if you are using SQL, you can use an approach similar to the demonstrated implementation in the attached web site.

    Hope this helps.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top