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

How to avoid PagingInfo takes add new record in it's record count?

Platform: ASP.NET Web Forms (Classic) |
Control: GridGroupingControl |
Published Date: April 30, 2011 |
Last Revised Date: August 21, 2019

By design PagingInfo will take the add new record into account. To avoid this we have to calculate it separately and modify the caption text using QueryCellStyleInfo event. Please refer the below code snippet which illustrates this:

C#

protected void GridGroupingControl2_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)

{

if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)

{

string str = e.Style.Text;

string[] parts = str.Split(new char[] { '(' });

string fpart = parts[0];

string spart = parts[1];

string[] parts2 = spart.Split(new char[] {' ' });

string p1 = parts2[0];

string p2 = parts2[1];

string p3 = parts2[2];

string p4 = parts2[3];

string p5 = parts2[4];

int num1 = Convert.ToInt32(p5);

num1=num1-1;

int num2 = Convert.ToInt32(p3);

if(num2 != 1)

num2=num2-1;

e.Style.Text =reccount.ToString()+" total"+" (Showing "+ num2.ToString()+"to"+ num1.ToString()+ ")";

}

}

VB

Protected Sub GridGroupingControl2_QueryCellStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs)

If e.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell Then

Dim str As String = e.Style.Text

Dim parts As String() = str.Split(New Char() { "("c })

Dim fpart As String = parts(0)

Dim spart As String = parts(1)

Dim parts2 As String() = spart.Split(New Char() {" "c })

Dim p1 As String = parts2(0)

Dim p2 As String = parts2(1)

Dim p3 As String = parts2(2)

Dim p4 As String = parts2(3)

Dim p5 As String = parts2(4)

Dim num1 As Integer = Convert.ToInt32(p5)

num1=num1-1

Dim num2 As Integer = Convert.ToInt32(p3)

If num2 <>1 Then

num2=num2-1

End If

e.Style.Text =reccount.ToString() & " total" & " (Showing " & num2.ToString() &"to"& num1.ToString() & ")"

End If

End Sub

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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