Display Data in a View
- Explore different modes for displaying data in a view
- Set properties for an element of the view.
- Browse the view as users of your application will see it
- Modify the view's URL to switch to a different display mode.
Estimated Time to Complete: 15 minutes
Skill level: Beginner
View files are the web pages that make up your application. Users interact with your application by means of views. In this section, we'll explore the different ways to use and edit views.
*Navigate to the default.view file in the Books folder, and display it in the DataWeb Designer. Click on the Design tab to edit the view graphically.
Displaying Data in Views
You can create views for lots of different purposes. You can display data in a view in a grid format, so that users can browse a lot of data at once. You can display detailed data one record at a time. Or, you can provide the user with a form for inserting new data or updating existing data. And you can display data in all of these ways with a single view file.
Let's explore the different ways to display a view now.
In the work area of the Designer, you'll see the data in the Books table in an area marked Data Region. The data region is the part of a view that displays data from a table, in this case the Books table. The fields that you added to the Books table appear within the data region.
Notice the tabs at the top of the data region, labelled Grid, Details, Update, and Insert. These correspond to the different ways you can display your view.
Grid mode displays your data as a datasheet, with rows and columns. Use this mode for displaying many records at once.
*Click on the Grid tab now to see your data displayed in grid mode.
Details mode displays records sequentially, in a report-style layout. Use this mode to display single or multiple records in greater detail than grid mode provides.
*Click on the Details tab now to see your data displayed in Details mode.
Insert mode displays a form for entering a new record in the table.
*Click on the Insert tab now to see your view in Insert mode.
Update mode displays a form for updating an existing record.
*Click on the Update tab now to see your view in Update mode.
Setting View Properties
Now click on the view's data region to select it. To the right of the work area, you'll see the Properties pane, showing the properties of the data region. You can set properties of the data region to modify its characteristics and behavior. Click on any element of your view to select it and set its properties.
The first property for the data region is the Default Display Mode property. This property specifies which in mode the data region is displayed by default -- grid, details, insert, or update. For a new view, the Default Display Mode property is set to Grid.
*Make sure that the Default Display Mode property is set to Grid.
Browsing a View
In the DataWeb Designer, you can modify the design of your view. The users of your application won't see your view in the DataWeb Designer, however; they'll see it in Browse mode. Let's take a look at how our view will appear to users. As you make changes to the view in the DataWeb Designer, you can refresh the view in Browse mode to see how it looks.
*To see your view as it will appear to the users of your application, click the Browse button. The view opens in a new browser tab, in Grid mode. Try looking at the view in different modes: click the Details button next to a record to display the record in Details mode, or click the Insert button to add a new record.
Modifying the View's URL
You can change a view's display mode while you're browsing the view by including the _mode parameter on the URL. Set the _mode parameter to grid, details, insert, or update.
*Try setting the view's display mode to Details from the URL. Modify a URL that calls the view so that it looks like the following example (but make sure to change the name of the application in the URL to your application's name):