Search these areas:
Help
Support Forums
Product Info



-Introduction
-DataWeb: What's New
-Creating an Application
-The DataWeb Designer
-Application Management
-Data Tables
-Data Tables
-Views
-Templates
-Components
-Data Analysis
-Members
-Security
-Importing
-Exporting
-FTP
-JavaScript
-Object Model
-Full-Text Search
-Domain and Email Hosting
-HotBlock Modules
-Account Management
-Glossary
-New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

Script Library

  Filter with an alphabetical list
 
  chubbard posted this script:
  This function writes out each letter of the alphabet, A to Z, and writes a link for each one that filters on a value starting with that letter. You can call it from within a view. Pass in the URL for the link (usually the same view) for the szViewUrl argument. For the szFilterField argument, pass in the name of a text field in your view.

webcall function outputAlphaLinks(szViewUrl, szFilterField)
{
    //we need to know which field we're filtering on
    if(!szFilterField)
        throw(Error(Errors.GeneralFailure, "Filter field must be provided."));

    //if there's no url provided, just append the filter parameter.
    if(!szViewUrl)
        szViewUrl = "?";
    //if there is a url provided, determine whether it has any parameters.
    else
        {
        var aURLPart = szViewUrl.split("?");
        //Append the filter parameter, either to the url or to the parameter list.
        if(!aURLPart[1])
            szViewUrl += "?";
        else
            szViewUrl += "&";
        }

    //loop through the upper-case ASCII characters
    for(var i = 65; i < 91; i++)
        {
        //output each letter with a link filtering on that letter.
        <ws:tags>
        <a href="<%=szViewURL + szFilterField + "~startswith="
            + String.fromCharCode(i)%>">
        <%=String.fromCharCode(i)%>
        </a>&nbsp;&nbsp;
        </ws:tags>;
        }
}

Here's an example that calls the function from within a view on a Products table:
...
<body>
<!--#
var c = classes.import("/alpha.ws");
c.outputAlphaLinks("/Products/default.view?_mode=grid", "ProductName");
#-->   
<ws:dataregion defaultmode="grid" actionbarposition="bottom" jumpbarposition="top">
...
 
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
DataWeb, 720 North 10th Street, A #145, Renton, Washington 98057 *425-583-5970* Fax 484-770-4706* Email Us