jqGrid
public abstract class jqGrid
| Field Summary | |
|---|---|
| string | Set the sql command for excel export. |
| string | Set a sql command used for the simple subgrid |
| boolean | |
| mixed | Custom call can be used again with custom function customFunc. |
| mixed | |
| function | Custom function which can be called to modify the grid output. |
| string the | The output format for the grid. |
| array | Store the names which are dates. |
| boolean | Enable disable debuging |
| string | Default enconding passed to the browser |
| string | Last error message from the server |
| integer | Maximum number of rows to be exported for the excel export |
| string | In case if no table is set, this holds the sql command for retrieving the data from the db to the grid |
| boolean | If set to true uses the PHP json_encode if available. |
| boolean | Determines if the log should be written to file or echoed. |
| array | Array which set which fields should be selected in case of mongodb. |
| array | Store the names for the int fields when database is MongoDB. |
| mixed | |
| boolean | Optimizes the search SQL when used in MySQL with big data sets. |
| boolean | Internal set in queryGrid if we should use count query in order to set the grid output |
| boolean | Obtain the SQL qurery from XML file. |
| boolean | If set to true all errors from the server are shown in the client in a dialog. |
| string | set a table to display a data to the grid |
| string | Get te current version |
| boolean | Defines if the xml otput should be enclosed in CDATA when xml output is enabled |
| Constructor Summary | |
|---|---|
| void | __construct(mixed db, str odbctype, resource -) Constructor |
| Method Summary | |
|---|---|
| void | logQuery(string sql, array data, array types, mixed input, mixed fld, str primary) Log query |
| void | debugout() Prints all executed SQL queries to file or console |
| void | Function to simulate 500 Internal error so that it sends the error to the client. |
| protected string | parseSql(string sqlElement, array params, bool bind) Prepares a $sqlElement and binds a parameters $params Return prepared sql statement |
| protected boolean | execute(string sqlId, array params, resource sql, boolean limit, integer nrows, integer offset, str order, str sort) Executes a prepared sql statement. |
| protected mixed | getSqlElement(string sqlId) Read a xml file and the higridSC and return the sql string Return string if the query is found false if not. |
| protected object | queryForObject(string sqlId, array params, boolean fetchAll) Return the object from the query |
| protected array | getStringForGroup(object group, array prm) Recursivley build the sql query from a json object |
| mixed | buildSearch(string filter, string otype) Build a search string from filter string posted from the grid Usually use this functio separatley |
| string | Return the current date format used from the client |
| void | setUserDate(string newformat) Set a new user date format using PHP convensions |
| string | Return the current datetime format used from the client |
| void | setUserTime(string newformat) Set a new user datetime format using PHP convensions |
| string | Return the current date format used in the undelayed database |
| void | setDbDate(string newformat) Set a new database date format using PHP convensions |
| string | Return the current datetime format used in the undelayed database |
| void | setDbTime(string newformat) Set a new database datetime format using PHP convensions |
| array | Return the associative array which contain the parameters that are sended from the grid to request, search, update delete data. |
| void | setGridParams(array _aparams) Set a grid parameters to identify the action from the grid Note that these should be set in the grid - i.e the parameters from the grid should equal to the GridParams. |
| object | selectLimit(string limsql, integer is, array array, int nrows, int offset, mixed params, str order, str sort) Will select, getting rows from $offset (1-based), for $nrows. |
| mixed | queryGrid(array summary, array params, boolen echo) Return the result of the query to jqGrid. |
| string | exportToExcel(array summary, array params, array colmodel, boolean echo, string filename) Export the recordset to excel xml file. |
| void | setPdfOptions(array apdf) Set options for PDF export. |
| protected null | rs2pdf(object rs, pdf created, array colmodel, mixed pdf, mixed summary) Convert a recordeset to pdf object |
exportToPdf(array summary, array params, array colmodel, string filename) Export the recordset to pdf file. |
|
| string | exportToCsv(array summary, array params, array colmodel, boolean echo, string filename, string sep, string sepreplace) Public method to export a grid data to csv data. |
| void | querySubGrid(array params, boolean echo) Return the result of the query for the simple subgrid The format depend of dataType variable |
| protected string | rs2excel(pdo recordset, array colmodel, boolean echo, string filename, array summary, mixed rs) From a given recordset returns excel xml file. |
| void | addUserData(array adata) Add a custom data to the grid footer row if it is enabled. |
public string $ExportCommand = ""
Set the sql command for excel export. If not set a _setSQL function is used to set a sql for export
public string $SubgridCommand = ""
Set a sql command used for the simple subgrid
public boolean $cacheCount = false
public mixed $customClass = false
Custom call can be used again with custom function customFunc. We can call this using static defined functions in class customClass::customFunc - i.e $grid->customClass = Custom, $grid->customFunc = myfunc or $grid->customClass = new Custom(), $grid->customFunc = myfunc
public mixed $customError = null
public function $customFunc = null
Custom function which can be called to modify the grid output. Parameters passed to this function are the response object and the db connection
public string the $dataType = "xml"
The output format for the grid. Can be json or xml
public array $datearray = array()
Store the names which are dates. The name should correspond of the name in colModel. Used to perform the conversion from userdate and dbdate
public boolean $debug = false
Enable disable debuging
public string $encoding = "utf-8"
Default enconding passed to the browser
public string $errorMessage = ''
Last error message from the server
public integer $gSQLMaxRows = 1000
Maximum number of rows to be exported for the excel export
public string $higridSC = ""
In case if no table is set, this holds the sql command for retrieving the data from the db to the grid
public boolean $jsonencode = true
If set to true uses the PHP json_encode if available. If this is set to false a custom encode function in jqGrid is used. Also use this to false if the encoding of your database is not utf-8
public boolean $logtofile = true
Determines if the log should be written to file or echoed. Ih set to created is a file HiGrid.log in the directory where the script is
public array $mongofields = array()
Array which set which fields should be selected in case of mongodb. If the array is empty all fields will be selected from the collection.
public array $mongointegers = array()
Store the names for the int fields when database is MongoDB. Used to perform right serach in MongoDB. The array should contain the right names as listed into the collection
public mixed $oper
public boolean $optimizeSearch = false
Optimizes the search SQL when used in MySQL with big data sets. Use this option carefully on complex SQL
public boolean $performcount = true
Internal set in queryGrid if we should use count query in order to set the grid output
public boolean $readFromXML = false
Obtain the SQL qurery from XML file.
In this case the higridSC should be set as xmlfile.sqlid.
The xmlfile is the name of xml file where we store the sql commands,
sqlid is the id of the required sql.
The simple xml file can look like this
< ?xml version="1.0" encoding="UTF-8"?>
public boolean $showError = false
If set to true all errors from the server are shown in the client in a dialog. Curretly work only for grid and form edit.
public string $table = ""
set a table to display a data to the grid
public string $version = '2.1'
Get te current version
public boolean $xmlCDATA = false
Defines if the xml otput should be enclosed in CDATA when xml output is enabled
public void __construct(mixed db, str odbctype, resource -)
Constructor
public void logQuery(string sql, array data, array types, mixed input, mixed fld, str primary)
Log query
public void debugout()
Prints all executed SQL queries to file or console
public void sendErrorHeader()
Function to simulate 500 Internal error so that it sends the error to the client. It is activated only if $showError is true.
protected string parseSql(string sqlElement, array params, bool bind)
Prepares a $sqlElement and binds a parameters $params Return prepared sql statement
protected boolean execute(string sqlId, array params, resource sql, boolean limit, integer nrows, integer offset, str order, str sort)
Executes a prepared sql statement. Also if limit is set to true is used to return limited set of records Return true on success
protected mixed getSqlElement(string sqlId)
Read a xml file and the higridSC and return the sql string Return string if the query is found false if not.
protected object queryForObject(string sqlId, array params, boolean fetchAll)
Return the object from the query
protected array getStringForGroup(object group, array prm)
Recursivley build the sql query from a json object
public mixed buildSearch(string filter, string otype)
Build a search string from filter string posted from the grid Usually use this functio separatley
public string getUserDate()
Return the current date format used from the client
public void setUserDate(string newformat)
Set a new user date format using PHP convensions
public string getUserTime()
Return the current datetime format used from the client
public void setUserTime(string newformat)
Set a new user datetime format using PHP convensions
public string getDbDate()
Return the current date format used in the undelayed database
public void setDbDate(string newformat)
Set a new database date format using PHP convensions
public string getDbTime()
Return the current datetime format used in the undelayed database
public void setDbTime(string newformat)
Set a new database datetime format using PHP convensions
public array getGridParams()
Return the associative array which contain the parameters that are sended from the grid to request, search, update delete data.
public void setGridParams(array _aparams)
Set a grid parameters to identify the action from the grid Note that these should be set in the grid - i.e the parameters from the grid should equal to the GridParams.
public object selectLimit(string limsql, integer is, array array, int nrows, int offset, mixed params, str order, str sort)
Will select, getting rows from $offset (1-based), for $nrows. This simulates the MySQL "select * from table limit $offset,$nrows" , and the PostgreSQL "select * from table limit $nrows offset $offset". Note that MySQL and PostgreSQL parameter ordering is the opposite of the other. eg. Also supports Microsoft SQL Server SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) Return object containing the limited record set
public mixed queryGrid(array summary, array params, boolen echo)
Return the result of the query to jqGrid. Support searching
public string exportToExcel(array summary, array params, array colmodel, boolean echo, string filename)
Export the recordset to excel xml file. Can use the ExportCommand. If this command is not set uses _setSQL to set the query. The number of rows exported is limited from gSQLMaxRows variable
public void setPdfOptions(array apdf)
Set options for PDF export.
protected null rs2pdf(object rs, pdf created, array colmodel, mixed pdf, mixed summary)
Convert a recordeset to pdf object
public exportToPdf(array summary, array params, array colmodel, string filename)
Export the recordset to pdf file. Can use the ExportCommand. If this command is not set uses _setSQL to set the query. The number of rows exported is limited from gSQLMaxRows variable
public string exportToCsv(array summary, array params, array colmodel, boolean echo, string filename, string sep, string sepreplace)
Public method to export a grid data to csv data. Can use the ExportCommand. If this command is not set uses _setSQL to set the query. The number of rows exported is limited from gSQLMaxRows variable
public void querySubGrid(array params, boolean echo)
Return the result of the query for the simple subgrid The format depend of dataType variable
protected string rs2excel(pdo recordset, array colmodel, boolean echo, string filename, array summary, mixed rs)
From a given recordset returns excel xml file. If the summary array is defined add summary formula at last row. Return well formated xml excel string
public void addUserData(array adata)
Add a custom data to the grid footer row if it is enabled. Also can be used to transport additional data in userdata array to be used later at client side. The syntax is $grid->addUserData(array("Name1"=>"Data1",...)); The method is executed after the sumarry rows are executed, so it can overwrite some summary data which is palced on the footer.