
Imports System.Data
Imports Telerik.Web.UI

Partial Class DefaultVB
    Inherits System.Web.UI.Page
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
        Dim grid As New RadGrid
        grid.ID = "ReportGrid"
        ' grid.RenderMode = RenderMode.Lightweight
        grid.AutoGenerateColumns = True
        grid.EnableViewState = False

        'grid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top
        'grid.MasterTableView.CommandItemSettings.ShowPrintButton = True
        'grid.MasterTableView.CommandItemSettings.ShowExportToPdfButton = True
        'grid.MasterTableView.CommandItemSettings.ShowExportToCsvButton = True
        'grid.MasterTableView.CommandItemSettings.ShowExportToExcelButton = True
        'grid.MasterTableView.CommandItemSettings.ShowExportToWordButton = True
        'grid.MasterTableView.CommandItemSettings.ShowRefreshButton = False
        'grid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = False
        'grid.EnableEmbeddedSkins = False
        'grid.RenderMode = RenderMode.Lightweight
        'grid.Skin =


        grid.AllowSorting = True
        grid.ClientSettings.Scrolling.AllowScroll = True
        grid.ClientSettings.Scrolling.UseStaticHeaders = True
        grid.ClientSettings.Scrolling.SaveScrollPosition = True


        'paging and virtualizaton

        grid.ClientSettings.Virtualization.EnableVirtualization = True
        grid.ClientSettings.Virtualization.InitiallyCachedItemsCount = 2000
        grid.ClientSettings.Virtualization.ItemsPerView = 100
        grid.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced

        grid.AllowPaging = True
        grid.PageSize = 1000

        grid.MasterTableView.TableLayout = GridTableLayout.Fixed
        grid.MasterTableView.PagerStyle.Visible = False

        'paging ...



        AddHandler grid.NeedDataSource, AddressOf ListReportGrid_NeedDataSource
        AddHandler grid.PreRender, AddressOf ListReportGrid_PreRender
        reportContentPanel.Controls.Add(grid)
    End Sub

    Private Sub ListReportGrid_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs)
        CType(sender, RadGrid).DataSource = OrdersTable()
    End Sub



    Private Function OrdersTable() As DataTable
        Dim dt As New DataTable()

        dt.Columns.Add(New DataColumn("OrderID", Type.GetType("System.Int32")))
        dt.Columns.Add(New DataColumn("OrderDate", Type.GetType("System.DateTime")))
        dt.Columns.Add(New DataColumn("Freight", Type.GetType("System.Decimal")))
        dt.Columns.Add(New DataColumn("ShipName", Type.GetType("System.String")))
        dt.Columns.Add(New DataColumn("ShipCountry", Type.GetType("System.String")))

        Dim PrimaryKeyColumns As DataColumn() = New DataColumn(0) {}
        PrimaryKeyColumns(0) = dt.Columns("OrderID")
        dt.PrimaryKey = PrimaryKeyColumns

        For i As Integer = 0 To 70 - 1
            Dim index As Integer = i + 1
            Dim row As DataRow = dt.NewRow()

            row("OrderID") = index
            row("OrderDate") = New DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index)
            row("Freight") = index * 0.1 + index * 0.01
            row("ShipName") = "Name " & index
            row("ShipCountry") = "Country " & index

            dt.Rows.Add(row)
        Next

        Return dt
    End Function



    Private Sub ListReportGrid_PreRender(ByVal sender As Object, ByVal e As EventArgs)
    End Sub
End Class
