How to stop PagingInfo from adding more records in Grid to its record count?
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