How to remove programmatically the paging in the grid of Microsoft Ligthswitch?

Most of the time we want to work with the grid, e.g., adding, editing, processing and even exporting, but when we loop to the grid using For Each we are bounded only to the current page.  To solve the problem you need to set the PageSize to zero of the Property collection of the grid then set it back again to its original PageSize.  Below is the example code:

        Private Sub exportClicked(sender As Object, e As System.Windows.RoutedEventArgs)
            Dim PageSize As Integer
            Dim dialog = New SaveFileDialog()

            PageSize = Me.Details.Properties.Table1Items.PageSize
            Me.Details.Properties.Table1Items.PageSize = 0

            dialog.Filter = "CSV (*.csv)|*.csv"
            If dialog.ShowDialog() = True Then
                Dim csv As String = GetTextCSV()
                Using stream As New StreamWriter(dialog.OpenFile())
                End Using
            End If

            Me.Details.Properties.Table1Items.PageSize = PageSize
        End Sub

Notice that before I tried to export the data in my grid to a CSV file I set the PageSize to zero. But that is not the only important thing here, notice that we use the Me.Details.Properties collection. I believe this collection holds many answers to some screen problems.

If you find this blog helpful, you can make the donation by clicking the Paypal button below.


2 thoughts on “How to remove programmatically the paging in the grid of Microsoft Ligthswitch?

  1. Great ! An alternative could be a for loop over the pages. The advantage is that by doing so , you can handle large amonunts of data. When you set the page size to 0, and you have let’s say 100.000 records you risk ending up with the request-response timeout

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s