How to Create and Use the Search Data Screen in LightSwitch Beta 2



Prologue:

In my previous article, we saw how to create and use the New Data Screen. In this article we shall discuss how to create and use a Search Data Screen in a LightSwitch application.

Preparing the Solution:

Create a LightSwitch Desktop application with the name "DesigningScreensInLSBeta2" as shown in the following figure.

SSwitch1.gif

Follow the [No: #] to create the Solution.

The Entity Designer:

Let us create a table.

SSwitch2.gif

This is a new screen of Beta 2 which is not available in Beta 1. Select the rounded option to create a new table.

After clicking on the "Create new table" option the following Entity Designer will be displayed.

SSwitch3.gif

To change the table name simply click on the header of the Entity Designer and give the name. In our sample application we have given the name Student.

When you are creating a Table [Entity], the field Id is the default one. At run time sometimes we don't need the Id to be displayed.

To make the visibility of the Id false, Select the Id and select the properties for the Id field.

SSwitch4.gif

Just uncheck the option "Display by Default". It will hide the Id from the running screen.

Creating the Search Data Screen:

There are two ways to create a screen. One is by selecting the Screen... button on the Entity Designer screen top.

SSwitch5.gif

Another way is to right-click on the Screens section in the Solution Explorer.

SSwitch6.gif

Adding Search Data Screen:

In this article we will mainly focus on the Search Data Screen.

SSwitch7.gif

To create the Search Data Screen, select the Search Data Screen from the screen template in the left side panel [No: 1].

Give the suitable name for the screen we are going to create. In this application we are using SearchStudent [No: 2].

The name should start with alphabets and contains only numbers and underscore.

Select the Entity to be displayed in the Search Data Screen. For our application we have selected the Students as the only Entity [No: 3].

The [No: 4] simply displays our screen to be displayed.

Where & When to use Search Data Screen:

Whenever we have a collection of data to be displayed and have to filter within the collection of data displayed we can use the Search Data Screen.

In the situation of having thousands of data for filtering, then the Search Data Screen will be the better one to use.

Changing the Appearance of Search Data Screen

SSwitch8.gif

We can change the appearance of the Search Data Screen using the Properties available. We can change the Control which is holding the Search data. By default the Rows Layout will be the control for the data collection to display.

Application in Action:

SSwitch9.gif

The above one is the Search Data Screen at run time.

In this we are having the Search text box at the right top corner of the screen with the reset option. One more beautiful option in the LightSwitch Search Data Screen is Export.

SSwitch10.gif

You can see the exported data from the filtered data on Search Screen to the Excel sheet.

Summary:

Most of the things we can only change at run time in the screen design. In this article, we have seen how to create and use the Search Data Screen in LightSwitch application.

Thanks for spending your precious time here. Please provide your valuable feedbacks and comments, which enable me to give a better article the next time.

Please rate this Article.

Thanks.


Similar Articles