Sort and Filter Data on Screen in LightSwitch 2012

In this article you will learn how to sort and filter data on the screen using Query Designer.

Getting Started

  1. Open Visual Studio 2012.
  2. Go to "File" => "New" => "Project..."
  3. Select "LightSwitch" in installed templates.
  4. Select "LightSwitch Application (Visual C#)".
  5. Enter the Name and choose the Location.
  6. Click "OK".

First, attach a data source or you can create a new table, this is my table data:


Image 1.

My screen looks like this:


Image 2.

As you will see on the screen the Order Date is in ascending order, so let's make it descending order.


Image 3.

Click on "Edit Query".


Image 4.

And select "Sort by column name" and "Order by" and hit F5 to run.


Image 5.

Now check order date, it's now in descending order.

Now we have added that query to the screen, now's let's add a query on the data source.


Image 6.

Right-click on the data source and click "Add Query".


Image 7.

Now add a new screen.


Image 8.

As you will see, that query is available in the screen data.

Now let's work on a filter query.

Let us fetch all records where the shipped date is not null.

One more time, add a new query using right-click on the data model and select "Filter".


Image 9.

Now add one more screen and select this query from screen data.


Image 10.

Now hit F5 to see the output.


Image 11.

You will see all the orders that have shipped date.

Up Next
    Ebook Download
    View all
    View all