Present What You Want

Labels
AJAX(112) App Studio(7) Apple(1) Application Builder(245) Application Factory(207) ASP.NET(95) ASP.NET 3.5(45) ASP.NET Code Generator(72) ASP.NET Membership(28) Azure(18) Barcode(2) Barcodes(3) BLOB(18) Business Rules(1) Business Rules/Logic(140) BYOD(13) Caching(2) Calendar(5) Charts(29) Cloud(14) Cloud On Time(2) Cloud On Time for Windows 7(2) Code Generator(54) Collaboration(11) command line(1) Conflict Detection(1) Content Management System(12) COT Tools for Excel(26) CRUD(1) Custom Actions(1) Data Aquarium Framework(122) Data Sheet(9) Data Sources(22) Database Lookups(50) Deployment(22) Designer(177) Device(1) DotNetNuke(12) EASE(20) Email(6) Features(101) Firebird(1) Form Builder(14) Globalization and Localization(6) How To(1) Hypermedia(2) Inline Editing(1) Installation(5) JavaScript(20) Kiosk(1) Low Code(3) Mac(1) Many-To-Many(4) Maps(6) Master/Detail(36) Microservices(4) Mobile(63) Mode Builder(3) Model Builder(3) MySQL(10) Native Apps(5) News(18) OAuth(9) OAuth Scopes(1) OAuth2(13) Offline(20) Offline Apps(4) Offline Sync(5) Oracle(11) PKCE(2) Postgre SQL(1) PostgreSQL(2) PWA(2) QR codes(2) Rapid Application Development(5) Reading Pane(2) Release Notes(183) Reports(48) REST(29) RESTful(29) RESTful Workshop(15) RFID tags(1) SaaS(7) Security(81) SharePoint(12) SPA(6) SQL Anywhere(3) SQL Server(26) SSO(1) Stored Procedure(4) Teamwork(15) Tips and Tricks(87) Tools for Excel(2) Touch UI(93) Transactions(5) Tutorials(183) Universal Windows Platform(3) User Interface(338) Video Tutorial(37) Web 2.0(100) Web App Generator(101) Web Application Generator(607) Web Form Builder(40) Web.Config(9) Workflow(28)
Archive
Blog
Sunday, April 5, 2009PrintSubscribe
Present What You Want

Data Aquarium Framework offers users of your applications impressive data filtering and reporting capabilities. Nevertheless there will always be a situation when you need to present a specific database record or a group of records on demand.

Filtering Via URL Parameter

The simplest method is to redirect your user to a specific page while supplying a record ID in the URL. For example, navigate to http://dev.codeontime.com/demo/nwblob/?EmployeeID=5 and you will see an employee with EmployeeID equal to 5 presented in the list.

image

Remove EmployeeID from the URL and all employees are displayed.

image

You are not limited to the record IDs only. For example, the following URL will select all employees with job title “Sales Representative” working in London office:

http://dev.codeontime.com/demo/nwblob?Title=Sales%20Representative&City=London

image

If the filtered field is visible by default then Data Aquarium Framework will automatically hide the corresponding field column in the grid view since the field value is presumed to be known to the user. There is little value repeating “Sales Representative” and “London” in each row in the picture above. You may want to verify that each employee is indeed working in London and has the title that we have specified.

Filtering Via an Element on The Page

You can also point your DataViewExtender components to read the filter value form any element on the page.

Add ~/Products.aspx page to the Data Aquarium project generated from Northwind database. Modify this page as shown below.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" 
    AutoEventWireup="true" CodeFile="Products.aspx.cs" 
    Inherits="Products" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <style type="text/css">
        div.Caption
        {
            font-weight: bold;
            padding: 4px 4px 4px 4px;
            background-color: #FDEAB1;
            color: #60302A;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Header1Placeholder" 
        runat="Server">
    Products
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header2Placeholder" 
        runat="Server">
    Northwind
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="BodyPlaceholder" 
        runat="Server">
    <asp:HiddenField ID="ProductID" runat="server" Value="5" />
    <!-- "edit" mode -->
    <div class="Caption">
        "Edit" Mode</div>
    <div id="EditProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="DataViewExtender1" runat="server" 
        TargetControlID="EditProduct"
        Controller="Products" 
        FilterSource="ProductID" FilterFields="ProductID" 
        ShowActionBar="false"
        StartCommandName="Edit" StartCommandArgument="editForm1" />
    <!-- "new" mode -->
    <div class="Caption">
        "New" Mode</div>
    <div id="NewProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="DataViewExtender2" runat="server" 
    TargetControlID="NewProduct"
        Controller="Products" ShowActionBar="false" 
        StartCommandName="New" StartCommandArgument="createForm1"
        PageSize="1" />
    <!-- "read" mode -->
    <div class="Caption">
        "Read" Mode</div>
    <div id="ViewProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="ProductListExtender" runat="server" 
        TargetControlID="ViewProduct"
        Controller="Products" 
        FilterSource="ProductID" FilterFields="ProductID" 
        ShowActionBar="false"
        StartCommandName="Select" StartCommandArgument="editForm1" />
</asp:Content>

You can see this page live at http://dev.codeontime.com/demo/filtering

At the top of the page there is HiddenField server control ProductID with its value set to 5.

    <asp:HiddenField ID="ProductID" runat="server" Value="5" />

Three different views are presented on the page. Let’s take a look at each of them.

The first view presents data in edit mode.

    <!-- "edit" mode -->
    <div class="Caption">
        "Edit" Mode</div>
    <div id="EditProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="DataViewExtender1" runat="server" 
        TargetControlID="EditProduct"
        Controller="Products" 
        FilterSource="ProductID" FilterFields="ProductID" 
        ShowActionBar="false"
        StartCommandName="Edit" StartCommandArgument="editForm1" />

It uses hidden field as a filter source and filters by the field ProductID.  The startup command displays view editForm1 in edit mode.

image

The second view displays an empty record and does not specify any filter.

    <!-- "new" mode -->
    <div class="Caption">
        "New" Mode</div>
    <div id="NewProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="DataViewExtender2" runat="server" 
        TargetControlID="NewProduct"
        Controller="Products" ShowActionBar="false" 
        StartCommandName="New" StartCommandArgument="createForm1"
        PageSize="1" />

The startup command is executed only after the data controller data is transferred to the client browser. This will cause the controller to read the first page of records from the database. We are reducing the number of returned records to one by specifying the corresponding page size. You can eliminate retrieval of any records if you link a business rules filter to the Products data controller.

Here is the screen shot of the view.

image

The third view uses the hidden field as a filter source to display a view of a single record in “read” mode in editForm1.

    <!-- "read" mode -->
    <div class="Caption">
        "Read" Mode</div>
    <div id="ViewProduct" runat="server">
    </div>
    <aquarium:DataViewExtender ID="ProductListExtender" runat="server" 
        TargetControlID="ViewProduct"
        Controller="Products" 
        FilterSource="ProductID" FilterFields="ProductID" 
        ShowActionBar="false"
        StartCommandName="Select" StartCommandArgument="editForm1" />

Here is how the view looks when rendered in a web browser.

image

Generated data controllers are configured by default to switch to grid1 view when user successfully executes Insert, Update, Delete, or Cancel command. You may want to play with configuration of actions in ~/Controls/Products.xml to make do what you see fit for your purposes. Read about it here.

Preventing Filtering

You may also want to prohibit any filtering at all. This is easy to accomplish if you assign None to the FilterSource property of the DataViewExtender component.

<aquarium:DataViewExtender ID="ProductExtender" runat="server" 
    TargetControlID="ProductList" Controller="Products" 
    FilterSource="None" />

Conclusion

It is very easy to filter and display records that you want to be presented. URL parameters and elements on the page can be automatically consumed as sources of filter values.

Next we will take a look at server-side filtering via code in business rules.