phpDocumentor jqAutocomplete
[ class tree: jqAutocomplete ] [ index: jqAutocomplete ] [ all elements ]

Class: jqAutocomplete

Source Location: /jqAutocomplete.php

Class jqAutocomplete

Class Overview

Located in /jqAutocomplete.php [line 15]



		
				Author(s):
		
  • Tony Tomov, (tony@trirand.com)
API Tags:
Abstract:  A PHP class to work with jQuery UI autocomplete. The main purpose of this class is to create a autocompleter on input element and provide the data from database to it. Work only with jQuery UI 1.8.4+
Usedby:  jqGridRender::setAutocomplete() - class. This requiere to include jqAutocomplete.php in order to work

Information Tags:
Version:  3.8.0.1
Copyright:  TriRand Ltd

Properties

Methods

[ Top ]
Property Summary
string   $ajaxtype   Determines the ajax type made to the server. Defaut is GET. Can be a POST
array   $aoptions   Stores the default options for the autocomplete
bollean   $cache   When set to true enables client side caching of the results.
string   $cachearray   Defines the uniquie cheche array (used in java script) when a cache is enabled.
array   $conn   Stores the database connection
string   $dbtype   Stores the database type needed in some db functions
string   $element   Stores the Id of the element. Should be uniquie value in order to have multiple autocomplates defined in one file.
string   $height   Determines the height of the autocomplete elemnt. Work only if $scroll option is set to true.
integer   $itemLength   Set the maximum rows send from the query to the autocomplete. If set to
boolen   $loadAll   Determines if the data should be loaded at once from the SQL siurce.
boolean   $runAll   Internal variable to determine whnever the script is run for first time.
string   $scroll   Determines if the content in autocomplete should have a scroll. Use this option with the height option - see below. If this option is not set the content will have height equal of the responce rows.
string   $searchType   Set the search type for the LIKE SQL operator.
string   $SelectCommand   Defines the select command for obtaining the data from the database.
mixed   $source   Stores the source for the autocomplete. Can be a string which should point to file from where to obtain the data. It can be array too.
string   $term   Stores the term parameter send from autocomplete and then used in query
string   $version   Info about the version

[ Top ]
Method Summary
jqAutocomplete   __construct()   Constructor
array   getACData()   This method is internally used to get the data.
mixed   getOption()   Return the the requested option of the autocomplete
object   queryAutocomplete()   Return the result for the autocomplete as PHP object. Determines automatically
string   renderAutocomplete()   Main method which do everthing for the autocomplete. Should be called after all settings are done. Note that in one file we can have more than one autocomplete definitions.
void   setEvent()   Set a JavaScript event for the autocomplete. For all the possible events
void   setLength()   Set the limit of the requested data in case of SQL command
boolean   setOption()   Set the desired option for autocomplete. For a full list of the option refer
none   setSource()   Set the source need for autocomlete to send a data. Can be a string or array. If the option is string then this is the url from where to obtain the data.
void   _setSrc()   Internal method used to set the source

[ Top ]
Properties
string   $ajaxtype = "GET" [line 137]

Determines the ajax type made to the server. Defaut is GET. Can be a POST

API Tags:
Access:  public


[ Top ]
array   $aoptions = array(
"appendTo"=>"body",
"disabled"=>false,
"delay"=> 300,
"minLength" => 1,
"source"=> null
)
[line 28]

Stores the default options for the autocomplete

API Tags:
See:  jqAutocomplete::setOption()
Access:  protected


[ Top ]
bollean   $cache = false [line 95]

When set to true enables client side caching of the results.

This prevent multiple queries to the database. Please use with care.

API Tags:
Access:  public


[ Top ]
string   $cachearray = "cache" [line 88]

Defines the uniquie cheche array (used in java script) when a cache is enabled.

API Tags:
Access:  protected


[ Top ]
array   $conn = null [line 39]

Stores the database connection

API Tags:
Access:  protected


[ Top ]
string   $dbtype = '' [line 44]

Stores the database type needed in some db functions

API Tags:
Access:  protected


[ Top ]
string   $element [line 58]

Stores the Id of the element. Should be uniquie value in order to have multiple autocomplates defined in one file.

API Tags:
Access:  protected


[ Top ]
string   $height = "110px" [line 153]

Determines the height of the autocomplete elemnt. Work only if $scroll option is set to true.

API Tags:
Access:  public


[ Top ]
integer   $itemLength = 10 [line 66]

Set the maximum rows send from the query to the autocomplete. If set to

false all the elements are sended to autocomplete

API Tags:
See:  jqAutocomplete::setLength()
Access:  protected


[ Top ]
boolen   $loadAll = false [line 131]

Determines if the data should be loaded at once from the SQL siurce.

Also when set to true only one requrest is done and the data then is stored at client side. No more requests to the server.

API Tags:
Access:  public


[ Top ]
boolean   $runAll = true [line 74]

Internal variable to determine whnever the script is run for first time.

Prevent running all commands (except data providing) when the autocomplete is crested

API Tags:
Access:  protected


[ Top ]
string   $scroll = false [line 146]

Determines if the content in autocomplete should have a scroll. Use this option with the height option - see below. If this option is not set the content will have height equal of the responce rows.

API Tags:
See:  jqAutocomplete::$height
Access:  public


[ Top ]
string   $searchType = "startWith" [line 123]

Set the search type for the LIKE SQL operator.

The possible values are startWith - set LIKE value%; contain - set LIKE %value%; endWith - set LIKE %value;

If the value does not match any of the above setting the SQL command is interpreted as it is without adding any additional strings.

API Tags:
Access:  public


[ Top ]
string   $SelectCommand = '' [line 110]

Defines the select command for obtaining the data from the database.

Usually this type of command contain the SQL LIKE operator. If the command contain where clause we suppose that this command contain LIKE operator. The serched fields should comtain ? plece holder in order to search om the term element send from the autocompleter. Example: SELECT field1, field2 FROM table WHERE field1 LIKE ? OR field2 LIKE ? As seen you should place a placeholder on the serched fields. The class add the term element automatically to the query. For additional information see the documantation

API Tags:
See:  jqAutocomplete::$searchType
Access:  public


[ Top ]
mixed   $source [line 51]

Stores the source for the autocomplete. Can be a string which should point to file from where to obtain the data. It can be array too.

API Tags:
Access:  protected


[ Top ]
string   $term = '' [line 81]

Stores the term parameter send from autocomplete and then used in query

if needed

API Tags:
Access:  protected


[ Top ]
string   $version = '3.8.0.1' [line 21]

Info about the version

API Tags:
Access:  public


[ Top ]
Methods
Constructor __construct  [line 161]

  jqAutocomplete __construct( [resource $db = null]  )

Constructor

Parameters:
resource   $db:  the database connection passed to the constructor. In case of array set to 'local'


[ Top ]
getACData  [line 332]

  array getACData( )

This method is internally used to get the data.


API Tags:
Access:  private


[ Top ]
getOption  [line 186]

  mixed getOption( string $option  )

Return the the requested option of the autocomplete

Parameters:
string   $option:  - the requested option or event.

API Tags:
Access:  public


[ Top ]
queryAutocomplete  [line 323]

  object queryAutocomplete( )

Return the result for the autocomplete as PHP object. Determines automatically

the placeholders (?) used into the SQL command


API Tags:
Access:  public


[ Top ]
renderAutocomplete  [line 394]

  string renderAutocomplete( string $element, [ $target = false], [boolean $script = true], [boolean $echo = true], [boolean $runme = true]  )

Main method which do everthing for the autocomplete. Should be called after all settings are done. Note that in one file we can have more than one autocomplete definitions.

Construct the autocomplete and perform Query operations.

Parameters:
string   $element:  The DOM element on which audocomplete should be applied
   $target:  - if set the value selection from autocomplete will be set to this element
boolean   $script:  - if set to false the script tag: <script type='text/javascript'> will not be included.
boolean   $echo:  if set to false the result is not echoed but returned
boolean   $runme:  - internal variable used into the jqGrid class

API Tags:
Access:  public


[ Top ]
setEvent  [line 224]

  void setEvent( string $event, string $code  )

Set a JavaScript event for the autocomplete. For all the possible events

refer the documentation

Parameters:
string   $event: 
string   $code: 

API Tags:
Access:  public


[ Top ]
setLength  [line 309]

  void setLength( mixed $num  )

Set the limit of the requested data in case of SQL command

Parameters:
mixed   $num:  - if set as number determines the number of the requestd itemd from the query. If set to false loads all the data from the query.

API Tags:
Access:  public


[ Top ]
setOption  [line 202]

  boolean setOption( string $option, [mixed $value = null]  )

Set the desired option for autocomplete. For a full list of the option refer

the documentation

Parameters:
string   $option: 
mixed   $value: 

API Tags:
Access:  public


[ Top ]
setSource  [line 236]

  none setSource( mixed $source  )

Set the source need for autocomlete to send a data. Can be a string or array. If the option is string then this is the url from where to obtain the data.

Parameters:
mixed   $source: 

API Tags:
Access:  public


[ Top ]
_setSrc  [line 245]

  void _setSrc( string $element  )

Internal method used to set the source

Parameters:
string   $element:  on which autocomplete is bound.

API Tags:
Access:  private


[ Top ]

Documentation generated on Thu, 16 Sep 2010 11:18:55 +0300 by phpDocumentor 1.4.3