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:

img1.jpg

Image 1.

My screen looks like this:

img2.jpg

Image 2.

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

img3.jpg

Image 3.

Click on "Edit Query".

img4.jpg

Image 4.

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

img5.jpg

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.

img6.jpg

Image 6.

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

img7.jpg

Image 7.

Now add a new screen.

img8.jpg

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".

img9.jpg

Image 9.

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

img10.jpg

Image 10.

Now hit F5 to see the output.

img11.jpg

Image 11.

You will see all the orders that have shipped date.


Similar Articles