This is a migrated thread and some comments may be shown as answers.

Grouping with Custom pagging and dynamic column

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jignesh
Top achievements
Rank 1
Jignesh asked on 04 May 2010, 04:10 PM
Hello Friends,

I have implemented custom pegging in my page.its working fine with dynamic column.
But in that grouping is not working.
I had done with below code.

.aspx page code

  <radG:RadGrid ID="dgResults" runat="server" AllowSorting="True" AllowPaging="true"
            AllowCustomPaging="true" PageSize="10" GroupPanel-Text="Drag and Drop Column Header To Regroup Column. "
            EnableAJAX="False" AllowFilteringByColumn="True" ShowGroupPanel="True" ExportSettings-ExportOnlyData="true"
            ExportSettings-IgnorePaging="true" ExportSettings-OpenInNewWindow="true" ShowFooter="false"
            Skin="Monochrome" BorderStyle="None" MasterTableView-CellPadding="0" MasterTableView-AutoGenerateColumns="false"
            CellPadding="0" EnableAJAXLoadingTemplate="False" GridLines="both" ClientSettings-ApplyStylesOnClient="true"
            Width="100%">
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="None" GroupLoadMode="Client"
                EnableColumnsViewState="true" TableLayout="Fixed">
                <ExpandCollapseColumn Visible="False">
                    <HeaderStyle Width="19px" />
                </ExpandCollapseColumn>
                <RowIndicatorColumn Visible="False">
                    <HeaderStyle Width="20px" />
                </RowIndicatorColumn>
            </MasterTableView>
            <ClientSettings EnableClientKeyValues="True" ReorderColumnsOnClient="True" AllowColumnsReorder="True"
                AllowGroupExpandCollapse="True" AllowDragToGroup="True">
                <Resizing AllowColumnResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="False" />
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" ScrollHeight="405px">
                </Scrolling>
            </ClientSettings>
            <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle>
        </radG:RadGrid>

.vb file code


Public Property pagenumber() As String
        Get
            Dim o As Object = ViewState("pagenumber")
            If o Is Nothing Then
                Return String.Empty
            End If
            Return CStr(o)
        End Get

        Set(ByVal Value As String)
            ViewState("pagenumber") = Value
        End Set
    End Property
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            CreateColumn()
        End If
    End Sub
    Private Sub CreateColumn()
        dgResults.Columns.Clear()
        If Not IsPostBack Then
            Dim boundName As New GridBoundColumn
            dgResults.MasterTableView.Columns.Add(boundName)
            boundName.DataField = "userid"
            boundName.HeaderText = "userid"
            boundName.UniqueName = "userid"
            boundName.SortExpression = "userid"

            Dim boundCompanyId As New GridBoundColumn
            dgResults.MasterTableView.Columns.Add(boundCompanyId)

            boundCompanyId.DataField = "username"
            boundCompanyId.HeaderText = "username"
            boundCompanyId.UniqueName = "username"
            boundCompanyId.SortExpression = "username"

            Dim boundroleid As New GridBoundColumn
            dgResults.MasterTableView.Columns.Add(boundroleid)

            boundroleid.DataField = "role_id"
            boundroleid.HeaderText = "role_id"
            boundroleid.UniqueName = "role_id"
            boundroleid.SortExpression = "role_id"
        End If
        If pagenumber = String.Empty Then
            pagenumber = 1
        End If
        Dim ds As DataSet = TT.test(pagenumber, 10) ' Get record
        dgResults.VirtualItemCount = ds.Tables(1).Rows.Count
        dgResults.DataSource = ds.Tables(0)
        dgResults.DataBind()
        ViewState("dttemp") = ds.Tables(0)
    End Sub
   Protected Sub dgResults_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles dgResults.NeedDataSource
        Dim ds As DataSet = TT.test(dgResults.CurrentPageIndex + 1, 10) ' Get record
        dgResults.VirtualItemCount = ds.Tables(1).Rows.Count
        Me.dgResults.DataSource = ds.Tables(0)
    End Sub


below Stored Procedure is used in my function

ALTER PROCEDURE testnew1
@iPageIndex INT,
@iMaxRows INT
AS
BEGIN
SET NOCOUNT ON;

DECLARE @iStart INT
SELECT @iStart = (@iPageIndex - 1) * @iMaxRows
DECLARE @iEnd INT
SELECT @iEnd = @iStart + @iMaxRows

IF OBJECT_ID (N'#TempNews',N'U') IS NOT NULL
DROP TABLE #TempNews

CREATE TABLE #Temp(
intUniqueID INT PRIMARY KEY IDENTITY(1, 1),
userid int,
username VARCHAR(500),
role_id  int
)

INSERT #Temp
SELECT userid,username,role_id from users
SELECT * FROM #Temp
WHERE intUniqueID > @iStart
AND intUniqueID <= @iEnd

DROP TABLE #Temp
select * from users
END


When i applied grouping on role_id column than i get the screen view as per attchment (Screen.jpg)

Please help me for grouping with custom pagging and dynamic column.

where is the problem in my code.

Thanks & Regards
Jignesh Patel

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 May 2010, 09:11 AM
Hello Jignesh,

From your code I have noticed that you use Advanced Data-binding (using NeedDataSource event) and at the same time calling DataBind() method. Please, note that you should never mix simple data-binding mode with advanced data-binding.

Additionally, for advanced features such as grouping, RadGrid must be bound through the NeedDataSource event.

For more information on Advanced data-binding take a look at the articles below:
Advanced Data-binding (using NeedDataSource event) help topic
Advanced Data Binding demo

I hope this helps.

Regards,
Pavlina
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jignesh
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or