PHP Generator Feature Demo
  • Themes
    • Default
    • Default compact
    • Cerulean
    • Cerulean compact
    • Cosmo
    • Cyborg
    • Darkly
    • Darkly compact
    • Facebook
    • Flatly
    • Journal
    • Lumen
    • Paper
    • Readable
    • Sandstone
    • Simplex
    • Slate
    • Slate compact
    • Spacelab
    • Superhero
    • Superhero compact
    • United
    • United compact
    • Yeti
    • Yeti compact
  • English
    • German
    • Brazilian
    • Czech
    • Danish
    • Spanish
    • Finnish
    • French
    • Hungarian
    • Italian
    • Dutch
    • Polish
    • Russian
    • Swedish
    • Slovak
    • Slovenian
    • Serbian
    • Turkish
    • Arabic
  • Learn more
    • PHP Generator Feature Demo
    • About this demo
    • Download project file for this demo
    • Check out other PHP Generator demos
    • NBA Database Demo
    • Security Demo
    • MySQL Schema Browser Demo
    • Learn more about our products
    • Try PHP Generator for free
    • SQL Maestro Group website
    • Follow us
    • Facebook
    • Twitter
    • YouTube
  • Recently added/updated
    • Grid Toolbar
    • Tabbed Forms
    • Stepped Area Chart
    • Candlestick Chart
    • Histogram Chart
    • Bubble Chart
    • Timeline Chart
    • Gantt Chart
    • Scatter Chart
    • Tree Map Chart
    • Export options
    • Invoice generation
    • Inline Button
    • HTML Wysiwyg
    • Watermarks
  • Data Grid
    • Table View
    • Card View
    • Autohiding Columns
    • Totals
    • Grid Header
    • Column Grouping
    • Record Comparison
    • Unicode Support
    • RSS
    • Custom Drawing
    • Custom Table Template
    • Custom Card Template
    • Custom Toolbar Template
    • Custom View Form
  • Grid Columns
    • Column Types
    • Text Truncating
    • Column Fixed Width
    • Formatting
    • Null Label
    • Hyperlinks
    • Html Display
    • Lookup Data View
    • Custom Rendering
  • Grid Options
    • Fixed Grid Width
    • Fixed Column Header
    • Bordered Table
    • Condensed Table
    • Line Numbers
    • Control Buttons Position
  • Data Sources
    • Table
    • View
    • Non-Updatable Query
    • Updatable Query
    • Updatable View
  • Master-Detail Views
    • Master/Detail Basics
    • Multiple Details
    • Nested Details
    • Card Mode Details
  • Data Input Forms
    • Separate Page
    • Modal Window
    • Inline Editing
    • Form Layouts
    • Tabbed Forms
    • Custom Separate Page
    • Custom Modal Dialog
    • Custom Inline Form
    • Wizard Form
    • Adding multiple records
    • Editors Overview
    • Validation
    • Client-side API
    • Dependent Lookups
    • On-the-Fly Adding
    • Quick Edit
    • Multi Edit
    • Custom Default Values
  • Editors
    • Text
    • Autocomplete
    • Text Area
    • HTML Wysiwyg
    • Spin & Range
    • Upload To Folder
    • Radio Group
    • Combobox
    • Dynamic Combobox
    • Cascading Combobox
    • Dynamic Cascading Combobox
    • Multiple Select
    • Checkbox Group
    • Common Properties
  • Data Filtering
    • Quick Filter
    • Filter Builder
    • Column Filter
    • Preliminary Filter
    • Selection Filters
    • Custom Filter - 1
    • Custom Filter - 2
  • Sorting
    • Sort By Click
    • Sort By Dialog
    • Default Sort Order
  • Partitioning
    • Range
    • List
    • Custom
  • Exporting & Printing
    • Grid
    • Single Record
    • Export Options
    • Custom Grid
    • Custom Single Record
    • User Defined Styles
  • Image Management
    • Image Galleries
    • Thumbnails
    • Linked Images
    • Multi Upload - 1
    • Multi Upload - 2
    • Watermarks
  • Charts
    • Pie Chart
    • Column Chart
    • Bar Chart
    • Line Chart
    • Area Chart
    • Geo Charts
    • Stepped Area
    • Candlestick
    • Histogram
    • Bubble
    • Timeline
    • Gantt
    • Scatter
    • Tree Map
    • Multiple Charts
    • Chart Placement
    • Customizing Charts
    • Dashboard
  • Many-to-Many Relations
    • Classic Junction Table
    • Handling Extra Columns
  • Fine-tuning & Tweaking
    • Custom Icons
    • Custom Theme
    • Custom Editor
    • Page Embedding
    • Ajax-based Validation
    • Color Themes
    • Barcodes Generation
    • Inline Button
    • Conditional Details
    • Using Ajax in Forms
  • Emailing
    • Basic Usage
    • Advanced Usage
  • Calculated Columns
    • Example - 1
    • Example - 2
  • Custom Templates
    • Grid View
    • Card View
    • Grid Toolbar
    • Single Record View
    • Separate Page Editing
    • Modal Dialog Editing
    • Inline Form Editing
    • Wizard Form
    • Custom Filter - 1
    • Custom Filter - 2
    • Export & Print: Data Grid
    • Invoice generation
  1. Data Filtering
  2. Filtering.Custom Filter (Simple Version)
    • Quick Filter
    • Filter Builder
    • Column Filter
    • Preliminary Filter
    • Selection Filters
    • Custom Filter - 2

Filtering.Custom Filter (Simple Version)

Page settings

Appearance

Here you can select the number of cards to be placed in a row for each of supported screen resolutions. Your current resolution is highlighted in this way.

Page size

Total record count: 223.

page(s).
Cancel Save changes
×

You can create your own filtering tool and use it instead of the built-in tools, or along with them. Usually all you need to implement such a filter is to insert an HTML code representing your filter form into a template, instruct PHP Generator to use the new template within the OnGetCustomTemplate event handler and handle entered parameters within the OnPreparePage event handler. In the example below we created a filter which allows you to filter countries by life expectancy.

Technical details are as follows (click a link below to see the appropriate code):

  • OnGetCustomTemplate event handler code.
  • Customized grid toolbar template including the custom filter template which contains a code of the filter form.
  • OnPreparePage event handler code.

An advanced version of this filter is represented on this page.

Add new
Refresh
Export
  • Export to Pdf
  • Export to Excel
  • Export to Word
  • Export to Xml
  • Export to Csv
Print
  • Print current page
  • Print all pages

        protected function doGetCustomTemplate($type, $part, $mode, &$result, &$params)
        {
            if ($part == PagePart::GridToolbar && $mode == PageMode::ViewAll) {
                $result = 'custom_simple_filter_grid_toolbar.tpl';
            
                $lifeExpectancyFilter = array(
                    'min' => 35,
                    'max' => 90
                );
                if (isset($_SESSION['simpleLifeExpectancyFilter'])) {
                    $lifeExpectancyFilter = array_merge($lifeExpectancyFilter, $_SESSION['simpleLifeExpectancyFilter']);     
                } 
                
                $params['LifeExpectancyFilter'] = $lifeExpectancyFilter; 
            }
        }
        protected function DoPrepare() {
            // handling custom filter parameters
            $lifeExpectancyFilter = array(
                'min' => -1,
                'max' => -1
            );
               
            if (GetApplication()->isGetValueSet('simpleLifeExpectancyFilter')) {
                $lifeExpectancyFilterValue = GetApplication()->GetGETValue('simpleLifeExpectancyFilter');
                if (is_array($lifeExpectancyFilterValue)) {
                    $lifeExpectancyFilter = array_merge($lifeExpectancyFilter, $lifeExpectancyFilterValue);
                }
            } elseif (isset($_SESSION['simpleLifeExpectancyFilter'])) {
                $lifeExpectancyFilter = array_merge($lifeExpectancyFilter, $_SESSION['simpleLifeExpectancyFilter']);
            }
            
            if ($lifeExpectancyFilter['min'] !== -1 && $lifeExpectancyFilter['max'] !== -1) {
                $this->dataset->AddCustomCondition(
                    sprintf('life_expectancy >= %d AND life_expectancy <= %d', 
                        $lifeExpectancyFilter['min'], $lifeExpectancyFilter['max']
                    )    
                );
                $_SESSION['simpleLifeExpectancyFilter'] = $lifeExpectancyFilter;
            } else {
                unset($_SESSION['simpleLifeExpectancyFilter']);
            }
            
            // auxiliary code
            $this->setDescription(file_get_contents("external_data/doc/filtering_custom_filter_simple.html"));
            
            $this->setDetailedDescription(
                '<br>' .
                '<div id="on-get-custom-template" class="event-code">' .
                    extractMethodCode($this, 'doGetCustomTemplate') . '</div>' .
                '<div id="on-prepare-page" class="event-code">' .
                    extractMethodCode($this, 'doPrepare') . '</div>' .
                '<div id="custom-grid-toolbar" style="display: none;">' .
                    extractTemplateFileCode('components/templates/custom_templates/custom_simple_filter_grid_toolbar.tpl') . 
                '</div>' .
                '<div id="custom-simple-filter" style="display: none;">' .
                    extractTemplateFileCode('components/templates/custom_templates/custom_simple_filter.tpl') . 
                '</div>'
            );
        }
{if $DataGrid.ActionsPanelAvailable}
    <div class="addition-block js-actions">
        <div class="btn-toolbar addition-block-left pull-left">
            {include file="list/grid_toolbar_add_button.tpl"}
            {include file="list/grid_toolbar_multi_upload_button.tpl"}
            {include file="list/grid_toolbar_refresh_button.tpl"}
            {include file="list/grid_toolbar_export_print_rss_buttons.tpl"}
            {include file="list/grid_toolbar_selection_button.tpl"}
        </div>

        {if not $isInline}
            <div class="addition-block-right pull-right">
                {include file="list/grid_toolbar_filter_builder_button.tpl"}
                {include file="list/grid_toolbar_sort_button.tpl"}
                {include file="list/grid_toolbar_settings_button.tpl"}
                {include file="list/grid_toolbar_description_button.tpl"}
            </div>
            {include file="list/quick_filter.tpl" filter=$DataGrid.QuickFilter}
        {/if}
    </div>
{/if}

{if $GridViewMode == 'card'}
    {include file='list/column_filters.tpl'}
{/if}

{* The string below is retained for compatibility *}
{$GridBeforeFilterStatus}

{* Custom Code *}
{include file='custom_templates/custom_simple_filter.tpl'}
{* /Custom Code *}

{include file='list/grid_filters_status.tpl'}

{include file='common/messages.tpl' type='danger' dismissable=true messages=$DataGrid.ErrorMessages displayTime=$DataGrid.MessageDisplayTime}
{include file='common/messages.tpl' type='success' dismissable=true messages=$DataGrid.Messages displayTime=$DataGrid.MessageDisplayTime}

<div class="js-grid-message-container"></div>
<div class="pull-right panel panel-primary">
    <div class="panel-heading">
        <span class="panel-title">Life Expectancy</span>
    </div>
    <div class="panel-body">
        <form id="custom-filter-form" class="form-inline" method="get">
            <div class="form-group">
                <label for="minLifeExpectancy">Min age</label>
                <input type="number" id="minLifeExpectancy" class="form-control input-sm"
                    name="simpleLifeExpectancyFilter[min]" value="{$LifeExpectancyFilter.min}" min="35" max="90"
                >
            </div>
            <div class="form-group">
                <label for="maxLifeExpectancy">Max age</label>
                <input type="number" id="maxLifeExpectancy" class="form-control input-sm"
                    name="simpleLifeExpectancyFilter[max]" value="{$LifeExpectancyFilter.max}" min="35" max="90"
                >
            </div>
            <button type="submit" class="btn btn-sm btn-primary">Apply</button>
            <a class="btn btn-sm btn-default js-reset-custom-filter">Reset</a>
        </form>
    </div>
</div>

 
Life Expectancy
Reset
Actions Code Country Continent Population Life Expectancy
SMR San Marino Europe 27,000 81.10
SOM Somalia Africa 10,097,000 46.20
SPM Saint Pierre and Miquelon North America 7,000 77.60
SSD South Sudan Africa 12,340,000 56.50
STP Sao Tome and Principe Africa 147,000 65.30
SUR Suriname South America 417,000 71.40
SVK Slovakia Europe 5,398,700 73.70
SVN Slovenia Europe 1,987,800 74.90
SWE Sweden Europe 8,861,400 79.60
SWZ Swaziland Africa 1,008,000 40.40
SYC Seychelles Africa 77,000 70.40
SYR Syria Asia 16,125,000 68.50
TCA Turks and Caicos Islands North America 17,000 73.30
TCD Chad Africa 7,651,000 50.50
TGO Togo Africa 4,629,000 54.70
THA Thailand Asia 61,399,000 68.60
TJK Tajikistan Asia 6,188,000 64.10
TKM Turkmenistan Asia 4,459,000 60.90
TMP East Timor Asia 885,000 46.00
TON Tonga Oceania 99,000 67.90
There are no records to display

Multiple Sort

Column Order

Filter builder

  • «
  • 1
  • ...
  • 9
  • 10
  • 11
  • 12
  • »

About this demo

This demo application contains 100+ pages and illustrates most of features provided by PHP Generator. Hope it will help you to create even more powerful websites for your users.

You can download the demo project from our website and run the demo on your webserver as described in readme.txt.

Download PHP Generator Free Trial

Legend
New Recently added or significantly updated pages.
Pro Pages illustrating features available only in the Professional edition of PHP Generator.

© 2002- SQL Maestro Group. Follow us:

Created with PHP Generator for MySQL. Want to learn more? Download the demo project!

Change your password

Change password for user ''

Passwords do not match. Please try again.

Close Change password