Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

In this lesson we are going to review Wayfast Datasets. A dataset allows us to connect a page with a data source like a database or an API. To depict how it works we will show you and example that include calling a database store procedure for retrieving information and displaying it in a Wayfast Application.    

Preconditions

We have 2 important preconditions before start working with Datasets.

  1. We need to

...

  1. connect the project with an existing or new database. You can find more details about in another lessons where we attached or created databases.

  2. We need to create an object in this database, for example, an Stored Procedure to interact with Dataset information.

Code Block
languagesql
CREATE PROCEDURE spHola_Mundo_AccionesTest_Insert
  @Data1  nvarchar(50)
  @Data2  nvarchar(50)
AS
  BEGIN
    INSERT Hola_Mundo_AccionesTest(Data1,Data2)
	SELECT @Data1, @Data2
  END
GO

This SP Stored Procedure will have 2 parameters . Once that the Stored Procedure is created, named as @data1 and @data2. Let’s execute the query to create the object in the database.

Now we can go back to Wayfast application and synchronize the SP stored procedure in the environment.

...

If the project is newly created and connected to a database, there’s no need to synchronize both objects. Dataset will retrieve all the objects associated between both entities automatically.

Let’s review how synchronize the objects in Wayfast. Keep in mind this action must be triggered inside the project before enter to the page where we are going to create the new dataset. Otherwise the stored procedure won’t be available in search field.

On Wayfast, focus on the active task at left side navigator page and click .

...

Click on “End Task” button related to project’s requirement.

...

...

A popup is displayed, click on “Synchronize” button. Now the stored procedure created in database will be available to connect with dataset.

How to create a new Dataset?

Go to “Project Pages” at top menu. Select any of the pages available in the project. Then click on “New Dataset” button

...

If we click on “Add relationship” button under “Control Run” field, we can link the Dataset with Controls inside the “Data Binding”. For more information, we can find an example in “Actions” lesson.

Click After that simply click on “Accept” button to save the dataset.

Now that we have our entity created, we know better how this Dataset will execute the Stored Procedure that we select and consequently the information can be displayed on the page from the very beginning.

...

Let’s verify the information available from DB and connect them to the Project, we need to make it visible in the application’s layout.can be quickly referenced from other controls in this page.

This is how it looks like:

...

How to connect the new Dataset with a Grid

...

?

If we create a new dataset and the page already has controls associated to a different dataset, let’s focus on “Controls” section. In this example, we have 3 grid columns linked to an old dataset.

...

Click on “Grid_Column” link at in “Control” column in each the row that we want to reassignbind . A popup is displayed with the information related to the control. Turn to “Data Binding” tab

...

Info

If page has multiple grid columns to reassign, we can use “Massive Mod” button which is a feature to easily make the bulk change.

...

Recap

We learnt about the importance of Datasets to interact with DB database and how the Store Procedure is needed for this purpose. We explained how some type of controls are specifically created to show the information from the Dataset to make it available at the moment we open the page.