Behavior: ModelSearchList

Applies a “list” function to this controller that will search members of its model (only DB based models)


modelNameOptional, default null String model name appropriate for $FP.getModel().  If not defined this controller’s model property will be used instead of calling $FP.getModel()
defaultSortOptional, default [] Array of {property:”colname”,direction:”asc|desc”} objects in the order the list should be sorted.  This can be overridden via params as either params.sort. see $ Object.setByPath for details on how to send and array of objects without javascript
searchFieldsOptional, default [all fields in model] What fields to search on
resultFieldsOptional, default [all fields in model] What fields to return
pageSizeOptional, default null If set, limits the number of rows returned.  Can be overridden via params.pageSize
pageSizeParamOptional, default “pageSize” Name of the parameter from the client that contains the pageSize
pageOptional, default null The 1-based page to retrieve from the model.  Can be overridden via
pageParamOptional, default “page” Name of the parameter from the client that contains the page number
searchOptional, default null Search query to apply.  See Search Queries below.  Can be overridden via
searchParamOptional, default “search” Name of the parameter from the client that contains the search string
baseQueryOptional, default “select resultFields from tablename where 1=1 base query to use for this search.  The search’s where clause criteria will be appended to this.  The underlying Myna.query will use “params” as its “values” property, so these are available to baseQuery

Search Queries

Search Queries are string that indicate case-insensitive partial string matches to apply to the searchFields.  Spaces create an implicit “AND” operation, the pipe (|) implies “OR” and the bang (!) indicates “NOT”.  Order does not matter


"engineer bob|sally !bobby"

in SQL:
col like '%engineer%'
and (
col like '%bob%'
or col like '%sally%'
and col not like '%bobby%'

Parameters available in views

pagepage number
pageSizepage size
resultMyna.Query object with query result


This behavior creates a “list” function on this controller that will list the members of this controller’s model.  It supports optional paging.  It can also search


function init(){


//in a view
<form action="<%=Html.url({action="list"})%>" method="get">
Search: <input name="search" value="ex: engineer bob|sally !bobby"><br>
Sort By:<select name="sort[0].property">
<option value="last_name"> Last Name</option>
<option value="first_name"> First Name</option>
<select name="sort[0].direction">
<option value="asc"> A-Z</option>
<option value="Desc"> Z-A</option>

Page Size: <input name="limit" value="25"><br>

Stores parameters to the request.
Object.prototype.setByPath=function (path,
sets a property or nested object property of this object