We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl always selects first row when paging

Thread ID:

Created:

Updated:

Platform:

Replies:

109167 May 31,2013 08:54 PM UTC Jan 5,2016 10:06 AM UTC ASP.NET Web Forms (Classic) 4
loading
Tags: GridGroupingControl
Neal Park
Asked On May 31, 2013 08:54 PM UTC

I am using the SetCurrent and SetSelected methods of the Record property to select the second row of the grid.  The initial page loads and the second record is selected properly but when I select another page then the selected row is always the first one, not the second (or third, etc).  I am using EnsureSelection of the GridGroupingControl but it seems like this is a feature/issue of the paging control since it only affects paged requests so I played with SetPagingParameters (of the GridPager) to set the StartRowIndex to 2 but that did not work either.  How do I select a different row other than the first one on a new page?  I need to do this dynamically, really.  In other words, if I can set it to row 2 I will need to be able to set any row for my production task.

Here is my code:


ASPX:
        <syncfusion:GridGroupingControl ID="MainGrid" runat="server"
            ViewStateMode="Enabled"
            ClientObjectID="__essentialGrid"
            AutoFormat="Office 2007 Blue"
            DataSourceCachingMode="None" >
        </syncfusion:GridGroupingControl>
            <syncfusion:GridPager ID="MainGridPager" runat="server" Width="715px" PagingControlID="MainGrid" PageSize="12" ViewStateMode="Enabled" Skin = "Office2007Blue" >
            <PagerItems>
                <syncfusion:NextPreviousGridPagerItem ShowFirstPageButton="true" ShowPreviousPageButton="true"
                            ShowLastPageButton="False" ShowNextPageButton="false" />
                <syncfusion:NumericGridPagerItem ButtonCount="7" />
                <syncfusion:NextPreviousGridPagerItem ShowFirstPageButton="false" ShowPreviousPageButton="false"
                            ShowLastPageButton="true" ShowNextPageButton="true" />
            </PagerItems>
        </syncfusion:GridPager>



CS (code-behind):

        protected void Page_Load(object sender, EventArgs e)
        {
            MainGrid.DataSource = GetData();
            MainGrid.EnsureSelection = false;

            //int recordIndex = ((MainGrid.CurrentPage - 1) * MainGridPager.MaximumRows) + 2;
            int recordIndex = 2;
            if (IsPostBack)
            {
                recordIndex = 15;
            }
            MainGrid.Table.Records[recordIndex].SetCurrent();
            MainGrid.Table.Records[recordIndex].SetSelected(true);
        }

        private List<CostItem> GetData()
        {
           ..
           (returns 103 items)
           ..
        }



Neal Park
Replied On June 4, 2013 06:04 PM UTC

I got this working by moving my row selection code from the Page_Load event into the Page_PreRender event.

.CS

        protected void Page_PreRender(object sender, EventArgs e)
        {
            int offset = 2;
            int recordIndex = (((MainGrid.CurrentPage - 1) * MainGridPager.MaximumRows) + offset) - 1; // -1 because index is zero based
            MainGrid.Table.Records[recordIndex].SetCurrent();
            MainGrid.Table.Records[recordIndex].SetSelected(true);
        }

HTH,

Neal

Rakesh D [Syncfusion]
Replied On June 6, 2013 07:44 PM UTC

Hi Neal,

 

Thanks for your update. We are glad to know that your issue has been resolved. Please let us know if you have any other concerns so that we will be happy to help you out.

 

Regards,

Rakesh D

 

 


Pramod Gaikwad
Replied On January 4, 2016 08:23 AM UTC

Hi ,
How to set active 1st row in page when Page change in javascript please let me know as early as possible

Kavitha Narayanan [Syncfusion]
Replied On January 5, 2016 10:06 AM UTC

Hi Pramod,

Query: How to set active 1st row in page when Page change in javascript.

We use EnsureSelection property to achieve your requirement. By default, the first row will be selected always on initial load and page will change when we set EnsureSelection property as true. So, we don’t have to achieve your requirement in javascript.

Please refer to the code and sample.

[Code]

<Syncfusion:GridGroupingControl ID="GridGroupingControl1" runat="server" AutoFormat="Office 2007 Blue" BorderCollapse="Separate"  DataSourceCachingMode="ViewState" DragSelectionBackColor="Yellow" GroupDropAreaCssClass="GridOffice2003BlueGroupDropArea" EnsureSelection="true" EnableCallbacks="False" HotTrackButtons="False">
</Syncfusion:GridGroupingControl>

Sample: http://www.syncfusion.com/downloads/support/forum/109167/ze/sample2030216458.zip

Regards,
Kavitha N.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;