ad_table_form

one of the documented procedures in this installation of the ACS
Usage:
ad_table_form   datadef   { type "select" }   { return_url "" }   { item_group "" }   { item "" }   { columns "" }   { allowed "" }
What it does:
builds a form for chosing the columns to display

columns is a list of the currently selected columns.

allowed is the list of all the displayable columns, if empty all columns are allowed.

Defined in: /web/philip/packages/acs-core/table-display-procs.tcl

Source code:


    # first build a map of all available columns 
    set sel_list [ad_table_column_list $datadef $allowed]
    
    # build the map of currently selected columns 
    set sel_columns [ad_table_column_list $datadef $columns]
    
    set max_columns [llength $sel_list]
    set n_sel_columns [llength $sel_columns]

    set html {}
    if {[string compare $item "CreateNewCustom"] == 0} {
        set item {} 
    }
    # now spit out the form fragment.
    if {![empty_string_p $item]} {
        append html "<h2>Editing <strong>$item</strong></h2>"
        append html "<form method=get action=\"/tools/table-custom\">"
        append html "<input type=submit value=\"Delete this view\">"
        append html "<input type=hidden name=delete_the_view value=\"1\">"
        append html "[export_form_vars item_group item]"
        if {![empty_string_p $return_url]} {
            append html "[export_form_vars return_url]"
        }
        append html "</form>"
    }

    append html "<form method=get action=\"/tools/table-custom\">" 
    if {![empty_string_p $return_url]} {
        append html "[export_form_vars return_url]"
    }
    if {[empty_string_p $item_group]} {
        set item_group [ns_conn url]
    }

    append html "[export_form_vars item_group]"
    if {![empty_string_p $item]} {
        set item_original $item
        append html "[export_form_vars item_original]"
        append html "<input type=submit value=\"Save changes\">"
    } else {
        append html "<input type=submit value=\"Save new view\">"
    }

    append html "<table>"
    append html "<tr><th>Name:</th><td><input type=text size=60 name=item [export_form_value item]></td></tr>"
    if {![empty_string_p $item]} {
        set item_original item
        append html "[export_form_vars item_original]"
        append html "<tr><td>&nbsp;</td><td><em>Editing the name will rename the view</em></td></tr>"
    }

    if {[string compare $type select] == 0} {
        # select table
        set options "<option value=\"\">---"
        foreach opt $sel_list { 
            append options " <option value=\"[lindex [lindex $datadef $opt] 0]\">[lindex [lindex $datadef $opt] 1]"
        }
    
        for {set i 0} { $i < $max_columns} {incr i} {
            if {$i < $n_sel_columns} {
                set match [lindex [lindex $datadef [lindex $sel_columns $i]] 0]
                regsub "(<option )(value=\"$match\">)" $options "\\1 selected \\2" out
            } else { 
                set out $options
            }
            append html "<tr><th>[expr $i + 1]</th><td><select name=\"col\">$out</select></td></tr>\n"
        }
    } else { 
        # radio button table
        append html "<tr><th>Col \#</th>"
        foreach opt $sel_list { 
            append html "<th>[lindex [lindex $datadef $opt] 1]</th>"
        }
        append html "</tr>"

        foreach opt $sel_list { 
            append options "<td><input name=\"col_@@\" type=radio value=\"[lindex [lindex $datadef $opt] 0]\"></td>"
        }
        for {set i 0} { $i < $max_columns} {incr i} {
            if {$i < $n_sel_columns} {
                set match [lindex [lindex $datadef [lindex $sel_columns $i]] 0]
                regsub "( type=radio )(value=\"$match\">)" $options "\\1 checked \\2" out
            } else { 
                set out $options
            }
            regsub -all {@@} $out $i out
            append html "<tr><th>[expr $i + 1]</th>$out</tr>\n"
        }
    }
    append html "</table></form>"

    return $html


philg@mit.edu