Sei sulla pagina 1di 40

Archive Docs

System Requirements
phpGrid is operating system independent. It works on both Windows and Linux as long as the
ollowing components are installed!

"#" $.% or later
Apache& 'omcat& or (icrosot II) web server
my)*L +., or above
I you are new to Apache-"#"-my).l& consider using /A(""& an integrated installation rom Apache
0riends. It installs Apache& "#"& and (y)*L in one batch installation and re.uires almost no
coniguration or both Windows and Linux operating systems.
Technical Overview
System Environment! Web1based
Intended Audience! 2on1'echnical 3sers& Web Developers&
Language: (ultilingual
Operating System: 4) Independent
Programming Language: "#"& 5*uery& 5.Grid& /#'(L& )*L
ata!ase: All (odern 6elational Database 7thru AD4db8
)ince the ma5or system architecture shit in phpGrid version +& the new version abandons the old
programming model which heavily relies on server side scripting& both in rendering and data
operations. (uch o the datagrid rendering now resides on the client side browser using 5*uery and
5.Grid. 'he server side is solely responsible or data 963D operations. 'he new version is much
more scalable than the previous generation& It also oers more eatures& such as subgrid and theme
roller.
"#" web1based editable datagrid now can be achieved in two lines o code rather than ive lines in the
previous version. It also use 9ascading )tyle )heets& or 9))& extensively or display related tasks& a
perect balance between simplicity and eatures.
php"rid supports all ma#or data!ases
php"rid Supports all ma#or we! !rowsers:
Installation
0irst and oremost& download the phpGrid rom the download page& and then extract the :ip ile
somewhere on your web server.
$on%iguration
;eore you begin coding using phpGrid& you must speciy database inormation in con%&php. con.php
is our phpGrid coniguration ile in which we speciy database connection parameters and path to the
phpGrid.
)tarting phpGrid version <& 'he constant names preiex with =P'P"RI(> to avoid potential naming
collison. "lease note that in "#" the method name and parameters are case sensitive.
con%&php %or php"rid version ) and a!ove *%ind php"rid version +,:
,
?
%
+
$
<
@
A
deine7B"#"G6IDCD;C#4)'2A(DB&BhostnameB8E -- database host name or '2) name 74racle only8
deine7B"#"G6IDCD;C3)D62A(DB& BusernameB8E -- database user name
deine7B"#"G6IDCD;C"A))W46DB& BpasswordB8E -- database password
deine7B"#"G6IDCD;C2A(DB& BsampledbB8E -- database name
deine7B"#"G6IDCD;C'F"DB& Bmys.lB8E -- database type
deine7B"#"G6IDCD;C9#A6)D'B&ButAB8E -- 4"'I42AL. Leave blank to use the deault charset
deine7B)D6GD6C644'B& B-phpGridColderB8E -- 36L to phpGrid older.

con%&php %or php"rid version -. /. /&0 *%ind php"rid version +,:
,
?
%
+
$
<
@
A
deine7BD;C#4)'2A(DB&BhostnameB8E -- database host name or '2) name 74racle
only8
deine7BD;C3)D62A(DB& BusernameB8E -- database user name
deine7BD;C"A))W46DB& BpasswordB8E -- database password
deine7BD;C2A(DB& BsampledbB8E -- database name
deine7BD;C'F"DB& Bmys.lB8E -- database type
deine7BD;C9#A6)D'B&ButAB8E -- 4"'I42AL. Leave blank to use the deault charset
deine7B)D6GD6C644'B& B-phpGridColderB8E -- 36L to phpGrid older.

I1PORTA2T: A!out SER3ER(ROOT
)D6GD6C644'& ormerly known as A;)C"A'#& represents the absolute URL to the phpGrid library
older on the web server. 'his value tells your script where to ind phpGrid library on the web server.
0or instance& i the 36L to get to the phpGrid is http:44www&yoursite&com4php"rid& or
http:44localhost4php"rid& the )D6GD6C644' should be =4php"rid=.
i the 36L to phpGrid is http:44www&yoursite&com4admin4php"rid& or
http:44localhost4admin4php"rid& the )D6GD6C644' should be =4admin4php"rid=&
and so orth.
4nce values in con.php are set& simply reerence phpGrid by adding the ollowing at on top o your
"#" code!
,
re.uireConce7HphpGrid-con.phpH8
E

ata!ase Type
phpGrid supports wide range o database types. )imply deine P'P"RI(5(T6PE parameter value
to your own database type. It can be one o the ollowing strings. 'he deault database type or phpGrid
is =mys.l>. "#"G6IDCD;C'F"D string is case sensitive.
P'P"RI(5(T6PE escription
mys.l (y)*L 7deault8
odbcCmss.l )*L )erver 7Inix 4nly8
odbcCmss.lCnative )*L )erver Windows native 7Download "#" )*L )erver Driver8
ociAJ$ 4racle 7Got '2)K8
postgres "ostGre).l
access (icrosot Access
db? D;?
db?1dsnless D;? D)21less connection
inormix Inormix
inormix@? Alternative Inormix Driver
odbc Generic 4D;9
A ull list o supported databases and naming convention are available in AD4db website. 2ot re.uired
but we encourage users to visit AD4db website. It helps you understand how phpGrid utili:es it under
the hood.
phpGrid now supports local array data source without using a database.

P'P "rid Oracle 7. 89g. 88g. 8:c
When using "#" datagrid or 4racle database with '2) 7'ransparent 2etwork )ubstrate8& replace the
database host name with the '2) 2ame in con.php e.g.
,deine7B"#"G6IDCD;C#4)'2A(DB& BF436 46A9LD '2) 2A(DB8E
php"rid $onstructor
Ater successul installation& call the constructor similar to the ollowing!
,Ldg M new 9CDataGrid7H)DLD9' I 064( 4rdersH& Horder2umberH& H4rdersH8E
'he details o phpGrid constructor is explained below!
__constructor($sql, $sql_key=id, $sql_table=, $db_connection=)
Parameter*s,:
Lsql! )*L )DLD9' statement. 'his is the only )*L statement users needs to implement.
'he )DLD9' statement must include the primary key as one o the columns i not using
the wildcard start7I8 in )DLD9' statement.
'his parameter can also be a local array 7version $.$N8. )ee phpGrid local array
data source usage example.
Lsql(;ey! 'he name o the database table primary key. 'he deault is =id>.
)tarting version <& phpGrid supports composite primary ;ey 76e.uires
Dnterprise or 3niversal License8 by simply passing an array o string as
<sql(;ey.
2ote that composite "O is not supported as oreign key reerential in
master-detail and subgrid.
Lsql(ta!le! 2ame o the database table used in the )*L statement. I not deined& the
table name is automatically parsed rom the )*L statementent.
Ld!(connection! 4ptional. )ince version +.%& the +th parameter was introduced and
used to overwrite connection parameters in con.php. It allows datagrid to reerence to a
dierence data source on the ly. )ee 6eerence to (ultiple Databases example or more
inormation on this parameter. I you have only one database& you can saely ignore this
parameter.
escription:
'his is our datagrid ob5ect constructor. 3se this method to create the phpGrid ob5ect.
3sually this is the irst line in your code.
E0ample:
Do 24' include W#D6D clause in Ls.l. Instead use setC.ueryCilter method 7version +.?N8 to
set .uery ilter.
I not using the wildcard star7I8& the )DLD9' statement (3)' include the primary key as one
o the columns.
Single primary ;ey:
,Ldg M new 9CDataGrid7H)DLD9' I 064( 4rdersH& Horder2umberH& B4rdersB8E
1 46 1
,Ldg M new 9CDataGrid7H)DLD9' I 064( 4rdersH& array7Horder2umberH8& B4rdersB8E
$omposite primary ;ey *Enterprise or =niversal license only,
,Ldg M new 9CDataGrid7H)DLD9' I 064( orderdetailsH& array7Hproduct9odeH& Horder2umberH8&
HorderdetailsH8E
9heck out the composite primary key online example.
set(query(%ilter*<>'ERE,
Parameters!
<>'ERE! ).l W#D6D statement to select data conditionally 7D4 24' include
W#D6D keyword8.
escription!
'he .uery ilter is essentially the W#D6D clause without the W#D6D. 'he method adds
W#D6D condition to already existing ).l )DLD9' statement. 3se this method i you
have W#D6D clause in your )*L statement. Fou should use the same )*L syntax& such
as single .uotes around non1numeric values& and even )*L unctions.

Remar;!
D4 24' include keyword =W#D6D> the ilter. phpGrid automatically adds W#D6D to
the .uery.
3se only )I2GLD *34'D around the iltered value.
E0ample!
,Ldg 1P setC.ueryCilter7HstatusMB)hippedB A2D FDA67shippedDate8 M ?JJ%H8E
ena!le(edit*, ?
* Please note this feature is only available in paid versions.
Parameters!
<edit(mode! 046(& or I2LI2D. 'he deault is 046(.
<operations! speciy allowed datagrid edit operations. ;y deault& all edit operations are
allowed.
9 M 9reate
6 M 6eview
3 M 3pdate
D M Delete
<edit(%ile! 4ptional. 3se a custom edit ile other than the deault =edit.php>. Do not set
this parameter unless you A;)4L3'DLF know what you are doingQ
escription!
When 0orm edit mode is used& additional icons appear in the data grid ooter used or
editing. When set to inline mode& the cells in the selected row become editable when the
row is clicked. 4nly a single row can be edited or either mode.
Remar;!
(ultiple records can be deleted when multiple select is enabled. )ee setCmultiselect78
or more inormation on this method.
0or inline edit& the user must press Enter ;ey to save changes
E0ample!
,
Ldg 1P enableCedit7B046(B& B963B8E -- Dverything is allowed but
delete
ena!le(e0port*,
Parameter*s,!
<type! Dxport type can be D/9DL& "D0& 9)G& or #'(L. 'he deault is D/9DL
escription!
When export is enabled& the export icon appears in the grid ooter. 'he datagrid can be
exported in D/9DL& "D0& 9)G or #'(L ormat. 'he Dxcel is exported in native Dxcel
/(L ormat. (ore ormats will be supported in the uture.
E0ample!
,Ldg 1P enableCexport7B"D0B8E
ena!le(resi@e*,
Parameter*s,!
<is(resi@a!le! boolean value indicating whether the phpGrid is resi:able.
<min(w! minimum resi:able width o the datagrid. 'he deault is %$J pixel.
<min(h! minimum resi:able height o the datagrid. 'he deault is AJ pixel.
escription!
When LisCresi:able is set to true& the small triangle shaped icon is displayed at the right
bottom corner o the php data grid. 'he grid can be resi:ed by simply click and drag the
icon using mouse. 'his is more convenient than setting the width and height by
programming.
Remar;!
'he method utili:es 5*uery 3I library. 'his is currently an experimental eature.
E0ample!
,
Ldg 1P
enableCresi:e7true8E
display*,
Parameter*s,:
<render(content! 4ptional. 'rue or alse. 6ender content to screen& deault value is set
to true.
escription:
'his is the method to call to display the datagrid. 'his is usually the last method to call.
It automatically stores the output to output buer irst beore rending the data grid.
Remar;!
3nless used together wtih getCdisplay78& itRs not necessary to supply a parameter value.
E0ample:
,Ldg 1P display78!
ena!le(de!ug*,
Note: this method is going to be deprecated in the future. Please use DEU! global constant instead.
Parameter*s,:
<de!ug! boolean value indicating whether to display debug message
escription!
Dnable debug displays phpGrid ob5ect as well as the current "#" session inormation. In
addition& /(L#ttp6e.uest& or ASA/& response data is displayed that occurs during
963D operations. 'his is helpul debugging inormation can be used during
development.
It also display the phpGrid version number and associated 5avascript libraries used.
Remar;!
(ake sure this method is not called& or the Ldebug parameter is set to alse& when
deployed in production.
E0ample!
,Ldg 1P enableCdebug7true8E
ena!le(search*,
Parameter*s,:
Lcan(search! boolean. When set to true& the search icon displays in the ooter& and the
integrated search is toggled when the icon is clicked.
escription:
'he integrated search provides an intuitive interace or searching data within the
datagrid. 'he user can search one or multiple ields. 2o additional programming is
re.uired. 'he datagrid is automatically rereshed and repopulated with results returned
rom the .uery through ASA/.
Remar;!
'he integrated search is toggle o by deault. 9lick on the )earch button in the ooter to
toggle on the integrated search.
E0ample:
,Ldg 1P enableCsearch7true8E
set(caption*,
Parameter*s,:
Lcaption! the text or the grid caption
escription:
When set& this method displays text above the column header as the datagrid
caption. When this method is not called& phpGrid sets the table name as the deault
caption. 0or example& the caption will be displayed as =4rders> when the table name is
=4rders>.
Remar;:
When caption is set to empty string& e.g. >& the space used or displaying caption will be
hidden& leaves only the column header& grid& and the ooter. 'o display the caption
without any text& uses > > without the .uote.
E0ample:
,
Ldg 1P setCcaption7BB8E -- this will hide the
caption
set(col(currency*,
Parameter*s,:
Lcol(name! column name
Lpre%i0! currency preix. 'he deault is 3)D symbol& L
<su%%i0! currency suix. 'he deault is blank.
LthousandsSeparator! 'he character as the thousands separator. 'he deault is the
comma character =&>.
LdecimalSeparator! 'he character as the decimal separator. 'he deault is the dot
character.
LdecimalPlaces! 'he number o digital is displayed ater the decimal point. 'he deault
is two.
Lde%ault3alue! 'he value display when the value return rom database is null or empty
string. 'he deault is J.JJ
escription:
'his is helper method to display currency value. It ormats column as currency when
displayed. 'he value is automatically unormatted during 963D operations.
E0ample:
,Ldg 1P setCcolCcurrency7HpriceH& HD36H& HH& H&H& ?& HJ.JJH8E
set(col(dynalin;*,
2ow supports local array 7version <8 Q
Parameter*s,:
<col(name! 2ame o column to display dynamic 36L
<!aseLin;=rl! 'he base 36L. e.g. =http!--www.example.com>
<dynaParam! 2ame o a single data ield "R an array o multiple ields. 'he deault is
=id> i omitted.
<addParam! 4ptional. "arameters with static value in addition to <dynaParam. 'hey
are added to the end o the 36L string. e.g. =TooMbar>
<target! 4ptional. 'his sets the value o the hyperlink ='arget> attribute. 'he available
options are!
Cnew
Cblank
Ctop
Cparent
escription:
'his method sets a speciic column to display #'(L hyperlink 36L based on dynamic
values. It is dierent rom setCcolClink78 method where it is simply a static link stored in
a data ield.
Remar;:
Developers should always check the validity o the dynamic 36L constructed when
using this method.
E0ample:
,-- a single dynamic ield as Ldyan"aram parameter
?
%
+
Ldg 1P setCcolCdynalink7Hproduct9odeH& Hhttp!--www.example.com-H& Horder2umberH&
BTampEooMbarB& HCtopH8E
-- an array o multiple dynamic ields as Ldyna"aram parameter
Ldg 1P setCcolCdynalink7Hproduct9odeH& Hhttp!--www.example.com-H& array7Horder2umberH&
Hcustomer2umberH& HpriceH8& BTampEooMbarB& HCtopH8E
set(col(edittype*,
Parameter*s,:
Lcol(name! 9olumn name
Lctrl(type! #'(L control type. A list o valid controls are!

te0t
te0tarea
select
chec;!o0
password
!utton
autocomplete U 2ewQ

L;eyvalue(pair! 'his parameter is only re.uired when the LctrlCtype is type =select> or
=checkbox>. It essentially represents list o value key pairs in the dropdown. e.g. =,!)an
0ranciscoE?!;ostonE%!2F9>. It is ignored i the control type is not =select>.I U #int! add
=:A> 7colon semicolon8 to the ront o the the key value pairs to add a blank dropdown
option.

v-&: =pdate:
you can now use values rom a database lookup table to bind the dropdown. )imply pass
)DLD9' statement or the LkeyvalueCpair when the LctrlCtype is =select>. 0or example!
#ELE$% &ey' value (R") (""
Lmultiple! 'his parameter is only used when control type is =select>. It indicates
whether multiple items can be selected in the list o options. 'he values are passed and
stored as a comma delimited string. e.g. =,&?&%V. 0or single value =select>& this is not
re.uired.
escription:
)et control o a speciic column used or grid editing. It displays #'(L input tag o
dierent type accordingly e.g. Winput typeM>text> -P& Winput typeM>textarea> -PW
Remar;:
'ext and textarea are set automatically based on the database access library AD4db
metatype as the deault edit control. 3sers do not need to understand how AD4db works
since phpGrid took care all the plumbing work internally. IsnRt that niceK
E0ample:
,
?
%
+
Ldg 1P setCcolCedittype7Hoice9odeH& HselectH& H,!)an 0ranciscoE?!;ostonE%!2F9H& alse8E
Ldg 1P setCcolCedittype7HisActiveH& HcheckboxH& H,!JH8E
-- bind dropdown menu to a lookup table
Ldg 1P setCcolCedittype7Hoice9odeH& HselectH& H)elect oice9ode&city rom
oicesH&alse8E
set(col(%ormat*,
Parameter*s,:
Lcol(name! Datagrid column name
L%ormat! 'he ormat types are!
integer
number
email
link
showlink
currency
date
checkbox
select
L%ormatoptions! "#" array stores ormat options o dierent ormatting.
escription:
Although this method is purely or cosmetic purpose& it is very useul and also practical
in many situations when displaying dierent type o data.
Depending on the type o ormat& it could have dierent ormat options. In most cases&
users only need to set column ormatting or =integer>& =number>& and =mail> using this
method. 0or =currencyR& =link>& and =showlink> ormats& phpGrid provides a number o
helper unctions to make ormatting simpler and easier. 'hey are
setCcolCcurrency78
setCcolClink78
setCcolCdate78
setCcolCdynalink78
'he helper unctions will be covered later in the documentation.
0or type =date>& users donRt have to do anything or ormatting. 'he ormat is
automatically set to =date> when the database data ield type is date or datetime.
In addition& the ormats are automatically set as =checkbox> or =select> i the edit type is
checkbox or select deined in setCcolCedittype78.
Remar;:
'hough all o the ormattings can be done in this method& it is recommended to use
helper unctions whenever possible. phpGrid ensures the ormatting is automated as
much as possible. Automation means less coding& and thus less room or
error. )implicity is what phpGrid strives or.
'o create custom ormatter& please see setCcolCproperty advanced method. )ome
5avascript knowledge is re.uired.
E0ample:
,
?
%
Ldg 1P setCcolCormat7B.uantityB&BintegerB& array7Bthousands)eparatorBMPB&B& BdeaultGalueBMPBJB88E
Ldg 1P setCcolCormat7HemailAddressH& HemailH8E
Ldg 1P setCcolCormat7HweightH& BnumberB& array7Hthousands)eparatorH MP H&H& Hdecimal)eparatorH MP
H.H& Hdecimal"lacesH MP B?B& HdeaultGalueH MP BJ.JJB88E
set(col(hidden*,
Parameter7s8!
Lcol(name! 9olumn name
Ledithidden! ;oolean value indicating whether the column is editable. 'he deault value
is set to true. 'his only applies when the edit mode is =046(>. A hidden column
cannot be editable in =I2LI2D> edit mode.
escription!
#ide a column in datagrid when displayed
Remar;!
'o hide column in both datagrid and orm& set the second parameter to alse
Important: 'he data are still sent to the browser but hidden using 9)) display!none.
0or sensitive data such as passwords and ))2 etc& do not use this method& instead do not
include those ields in your )*L at all.
E0ample!
,
?
%
+
-- hide only in grid display
Ldg 1P
setCcolChidden7Bemployee2umberB8E
-- hide in both gird and edit orm
Ldg 1P setCcolChidden7BD4;B& alse8E

Tip:
'o do the reverse& meaning to have a ield appear in grid& but not in the orm& use setCcolCproperty set
editable to alse and hidedlg to true.
,
Ldg1PsetCcolCproperty7B94L3(2C2A(DB&
array7BeditableBMPalse&BhidedlgBMPtrue88E
set(col(img*,
Parameter7s8!
Lcol(name! 9olume name
L!ase(=rl! 4ptional. ;ase 36L to image 7added in version $.J8
escription!
Display as image or a data ield in data grid. 'he optional second parameter is added in
version $.J. It speciies the base 36L-target or all relative 36Ls to images ile.
E0ample!
Assuming the productImag value is =abc.5pg>& the ollowing will render a img tag similar to
. 'he ?nd parameter =-images-> orm the base 36L to the =abc.5pg>
,
Ldg 1P setCcolCimg7HproductImageH&
H-images-H8E
set(col(lin;*,
Parameter7s8!
Lcol(name! 9olumn name
Ltarget! #yperlink target attribute. 'he deault is Cnew
escription!
Display the text in column as a static hyperlink.
Remar;!
3se this method or displaying static #'(L hyperlink. 0or dynamic links& use
set*col*dynalin&78 method.
E0ample!
,Ldg 1P setCcolClink7Hproduct9odeH8E
set(col(readonly*,
Parameter7s8!
Lcol(names! 9omma delimited one or more column names
escription!
)et one more more columns as read only ield
E0ample!
,
Ldg 1P setCcolCreadonly7H))2& lastname&
employee2umberH8E
set(col(required*,
Parameter7s8!
Lcol(names! 9omma delimited one or more column names
escription!
)et one more more columns as re.uired ield during edit
E0ample!
,
Ldg 1P setCcolCre.uired7Hphone&
emailH8E
set(col(title*,
Parameter7s8!
Lcol(name! 9olume name
Lnew(title! Display title in grid column header
escription!
9hange data grid column header text rom the deault data ield name to more user
riendly name
Remar;!
'he deault column header text is the database table data ield name
E0ample!
,
Ldg 1P setCcolCtitle7HnameH& H0irst
2ameH8E
set(dimension*,
Parameter7s8!
Lwidth! Datagrid width
Lheight! Datagrid height. 'he deault is ,JJX which expanses grid vertically to the
entire browser height
<shrin;ToBit! true or alse. I set to alse& hori:ontal bar will appear when the total
width o grid is wider than the dimesion width. 'he deault is true.
escription!
)et the overall height and width o phpGrid
Remar;:
It is recommended to set Lshrin;ToBit to alse when there are a large number o
columns to display.
E0ample!
,Ldg 1P setCdimension7AJJ& <JJ8E
set(#q(datatype*,
Parameter7s8!
Ldatatype! Internal data source type. It can be either =+son> or =,ml=. 'he deault is
=+son=.
escription!
(anually sets data type used by 5.Grid when displaying data grid.
Remar;!
In most cases& you do not need to call this method.
set(#q(editurl*,
Parameter7s8!
Lurl! 36L
escription!
(anually set 36L used or editing. 'he deault 36L is edit.php. phpGrid takes care all
o data insert& delete& and update in edit.php. 2o coding is re.uired.
Remar;!
4nly use this method when the users need to mannually handle data update using their
own routin.
In most cases& you do not need to call this method.
set(#q(grid2ame*,
Parameter7s8!
Lgrid(name! 3ni.ue name o the datagrid used internally by phpGrid
escription!
(anually set the un.iue name o the datagrid. ;y deault& the name is the database table
name associated with the grid.
Remar;!
In most cases& you do not need to call this method.
set(masterdetail*, ?
* Please note this feature is only available in paid versions.
Parameter7s8!
Lo!#(grid! phpGrid ob5ect as the detail datagrid
L%;ey! 0oreign key to the detail table.
escription!
'his method sets the master detail& or the parent child& relationship between datagrids.
'he phpGrid went the extra mile to make creating the master detail datagrid a simple
task or developers. 'he primary key value o master datagrid is auomatically retrieved
when user selects a row and used as the value to the oreign key in the detail grid. 'he
detail grid renders dynamically based on the row selected in parent grid.
Remar; *important,!
'he detail grid is a regular phpGrid ob5ect and can have the same methods like any other
phpGrid& such as description title& sort& and update etc. A master detail can have one or
more detail datagrid.
'he oreign key& or Lkey& does 24' necessarily have to have the same name as the
master table primary key& as long as the same name exists in both master and detail
tables.
When oreign keys donRt have the same name& you should use )*L alias in the master
grid. #owever& i the grid is editable& itRs important to call setCcolCreadonly78 and set the
new alias to be read only.
5y leaving the %oreign ;ey %ield !lan; in detail grid. master grid will pre%ill its
detail grid with the value o% the %oreign ;ey !e%ore the new record is saved4inserted
to the data!ase ta!le& Or simply hide the entire %oreign ;ey column *3ersion -&/&/
and a!ove only,&
E0ample!
,
?
%
+
-- orderId exists in both master table74rders8 and detail table74rderDetails8
Ldg M new 9CDataGrid7H)DLD9' orderId& orderDate& customerId 064( 4rdersH& Horder2umberH&
H4rdersH8E
Lsdg M new 9CDataGrid7H)DLD9' lineId& orderId& product9ode& price 064( 4rderDetailsH&
HlineIdH& H4rderDetailsH8E
Ldg 1P setCmasterdetail7Lsdg& BorderIdB8E
When oreign keys donRt have the same name& you can use )*L alias in the master grid. Ddit will ail
when using )*L alias in detail grid. ;ut also remember to set the alias to be read only i the grid is
editable.
,
?
%
+
$
-- productId is )*L alias to product2o in master table7"roduct"arts8& then used as oreign key to link
to detail table7"roducts8.
Ldg M new 9CDataGrid7H)DLD9' part2o& part2ame& product2o A) productId 064( "roduct"artsH&
Hpart2oH& H"roduct"artsH8E
Ldg 1P enableCedit7BI2LI2DB& B963DB81PsetCcolCreadonly7HproductIdH8E
Lsdg M new 9CDataGrid7H)DLD9' productId& product2ame& productDescription 064( "roductsH&
HproductIdH& H"roductsH8E
Ldg 1P setCmasterdetail7Lsdg& BproductIdB8E
set(multiselect*,
Parameter7s8!
Lmultiselect! ;oolean value indicates whether the multiselect is allowed
escription!
When parameter Lmultiselect is set to true& a checkbox is shown to the let o each row.
It is currently only used or enabling deleting multiple records. (ore unctions will be
added to this eature in the uture.
E0ample!
,
Ldg 1P
setCmultiselect7true8E
set(pagesi@e*,
Parameter7s8!
Lpagesi@e! An integer value indicates number o results displaying in a page in the
datagrid
escription!
'his method changes the deault pagination o the datagrid. 'he deault is ?J.
Remar;!
"agination is disabled when setCscroll78 is set to true. )ee setCscroll78 or more
inormation.
E0ample!
,
Ldg 1P setCpagesi:e7+J8E -- display up to +J rows in a
page
set(row(color*,
Parameter7s8!
Lhover(color! ;ackground color when mouse is over a row
Lhighlight(color! ;ackground color when a row is clicked on
Lalt(color! Alternating row color
escript!
'his method is pure cosmetic. When modiied& it overwrites color o 5*uery 3I
properties!
ui1state1hover&
ui1state1highlight
ui1priority1secondary
E0ample!
,
Ldg 1P setCrowCcolor7ByellowB& BlightblueB&
BlightgrayB8E
set(scroll*,
Parameter7s8!
Lscroll! ;oolean value indicates wheter
Lheight! phpGrid height
escription!
3se vertical scroll to load data. 'he datagrid will not load everything at once and will
hold all the items rom the start through to the latest point ever visited. 'his prevents
memory leaks rom happening.
Remar;!
"agination is disabled when scroll is set to true.
'he deault height is +JJ when scroll is true and should never be R,JJXR.
E0ample!
,
Ldg 1P
setCscroll7true8E
set(sortname*,
Parameter7s8!
Lcol(name! 9olumn name to sort
<sort(order! YA)9R or YDD)9R. Deault value is YA)9R 7version +.+N8
escription!
)et column sort by and sort order when datagrid is initially loaded.
E0ample!
,Ldg 1P setCsortname7Bproduct2ameB& BDD)9B8E
set(su!grid*,
Parameter7s8!
Lo!#(grid! phpGrid ob5ect as subgrid
Ls(%;ey! subgrid oreign key.
Lm(%;ey! 4ptional. (aster oreign key. 7ver +.$N8.
escription!
'he method displays inline and read1only detail grid rather than in separate datagrid
table. It is similar to setCmasterdetail78 except it can takes an additional parameter as the
oreign key rom master grid. When ignored& phpGrid assumes that mCkey has the same
value as the sCkey.
Remar;!
Ddit is currently not supported in subgrid.
2ested subgrid is currently not supported& 2ested-drill1down subgrid is now supported
7version <N8.
'he order o the ?nd and %rd parameter matters&
When the subgrid is the same table7sel1reerence& in database term8 as the master grid&
subgrid must use an dierent alias as table name in the select statement.
All the grid properties and method should be called ;D046D setCsubgrid is called.
Do not include YW#D6DR in setC.ueryCilter78 when used on subgrid.
E0ample!
,
?
%
Ldg M new 9CDataGrid7H)DLD9' I 064( ordersH& Horder2umberH& HordersH8E
Ldg1PenableCedit7HI2LI2DH& H963DH8E
+
$
<
@
A
Z
,J
,,
,?
,%
,+
,$
,<
,@
-- ?nd grid as detail grid
Lsdg M new 9CDataGrid7H)DLD9' I 064( orderdetailsH& array7HorderLine2umberH&
Hproduct9odeH8& HorderdetailsH8E
Lsdg1PenableCedit7HI2LI2DH& H963DH8E
-- %rd grid as detail grid.
Lsdg? M new 9CDataGrid7H)DLD9' I 064( productsH& array7Hproduct9odeH8& HproductsH8E
Lsdg?1PenableCedit7HI2LI2DH& H963DH8E
-- passing the detail grid ob5ect as the irst parameter& then the oreign key name.
-- setCsubgrid should be the last method to call beore display
Lsdg1PsetCsubgrid7Lsdg?& Bproduct9odeB8E
Ldg1PsetCsubgrid7Lsdg& Border2umberB8E
Ldg1Pdisplay78E
set(theme*,
Note: starting version -' you can set a global constant .%/E)E0 in conf.php to change all of your
datagrid themes 1ithout calling set*theme23 method individually.
Parameter7s8!
Ltheme(name! 'heme name
escription!
'his is the phpGrid ='heme 6oller>. phpGrid bundles the ollowing themes rom 5*uery
3I!
dot1luv
excite1bike
lick
overcast
pepper1grinder
redmond
smoothness
start
ui1darkness
ui1lightness
aristo [[[[U 7Premium theme8 I
cobalt [[[[U 7Premium theme8 I
'he deault theme is YstartY.
E0ample!
,
Ldg 1P
setCtheme7BlickB8E
I "remium themes are currently available to Dnterprise and 3niversal Licenses.
set(col(width*,
Parameters!
<col(name: column name
<width: width
escription!
)peciy column width in pixel. 'he width should be an integer value.
E0ample!
,
Ldg 1P setCcolCwidth7HcommentsH&
$JJ8E
set(group(properties*, ?
* Please note this feature is only available in paid versions.
Parameters!
<column(name: column name or grouping
<group$ollapsed: boolean value indicating whether to expand or collapse grouping
when displayed. 'he deault is %alse.
<showSummaryOn'ide! boolean value indicating whether to display group summary
when grouping is collapsed. 'he deault is true.
escription:
Group grid values simply by speciying a column name.

Remar;!
)ingle level grouping is currently supported.
When grouping is enabled& the ollowings methods are disabled!
setCscroll78E
enableCrownumbers78E
setCsubgrid78E
E0ample:
,
Ldg 1P
setCgroupCproperties7Bcustomer2umberB8E
set(group(summary*, ?
* Please note this feature is only available in paid versions.
Parameters!
<column(name! column name or grouping
<summaryType! summary type. It can be one o the types below
sum
count
avg
min
max
escription:
Display group summary o a speciic summary type& such as sum or max& in the group
summary ooter.

Remar;:
'his method must be used together with setCgroupCproperties78 method.
E0ample!
,
?
%
Ldg 1P setCgroupCproperties7Bcustomer2umberB8E
Ldg 1P setCgroupCsummary7BamountB&BsumB8E
Ldg 1P
setCgroupCsummary7Bcheck2umberB&BcountB8E
ena!le(rownum!ers*,
Parameters!
<has(rownum!ers! boolean value indicating whether row number is displayed.
escription!
Display row number beore each row.

E0ample!
,
Ldg 1P
enableCrownumbers7true8E
set(col(align*,
Parameters!
<col(name: column name
<align: alignment direction! =let>& =center>& or =right>.
escription!
#ori:ontal alignment o text in a column. 'he deault alignment is let.
E0ample!
,
Ldg 1P setCcolCalign7BamountB&
BrightB8E
ena!le(advanced(search*,
Parameters!
<has(adsearch: boolean value. )et true to enable advanced search
escription!
Advanced search is dierent rom the integrated search 7see enableCsearch788. It can
apply mulitple conditionals to a single ield during advanced search. It is super lexible
and easy to use.
E0ample!
,
Ldg 1P
enableCadvancedCsearch7true8E
set(locale*,
Parameters!
<locale: language locale. List o values are! !g. cat. cn. cs. de. d;. el. en. %a. %i. %r. he.
is. it. #a. nl. no. pl. pt. ro. ru. sp. sv. tr. ua.
escription!
I you are using phpGrid in a language rather Dnglish& you may want the datagrid to
display appropriate system text used by phpGrid such as =)ubmit>& =2ext>& ="age>&
=0ind> etc. 'he language locale iles are located in 5s\src\i,An directory.
E0ample!
,Ldg 1P setClocale7HrH8E -- 0rench locale
set(conditional(%ormat*, ?
* Please note this feature is not available in Lite and asic versions.
Parameters!
<col(name: column name
<type: 9DLL or 64W
<%ormatoptions: array that stores condition and css style options
escription!
0ormat a cell based on the speciied condition. 9DLL ormats the a single cell. 64W
ormats the entire row.

Lormatoption is the most important parameter which itsel is an array contains three
elements!
condition&
value&
css.

'he elements are described in details as the ollowing!
'he irst parameter& condition& has the ollowing available value.
eq! D.uals
ne! 2ot D.uals
lt! Less than
le! Less than or D.ual
gt! Greater than
ge! Greater than or D.ual
cn! 9ontains
nc! Does not 9ontain
!w! ;egins With
!n! 2ot ;egins With
ew! Dnds With
en! 2ot Dnds With
'he second parameter& value& is the comparing value in the right operand.
css parameter in Lormattoptions is an array collection that contains css style element or
current cell or row.
E0ample!
,
?
%
+
$
<
@
A
Z
,J
,,
,?
,%
--0ormat a cell based on the speciied condition
Ldg1PsetCconditionalCormat7Horder2umberH&H9DLLH&array7HconditionHMPHe.H&
HvalueHMPH,J,J@H&
HcssHMP array7HcolorHMPH]H&Hbackground1colorHMPHgreenH888E
Ldg1PsetCconditionalCormat7Hcustomer2umberH&H9DLLH&array7HconditionHMPHe.H&
HvalueHMPH,+,H&
HcssHMP array7HcolorHMPHredH&Hbackground1
colorHMPH]D9D9D9H888E
-- 0ormat a row based on the speciied condition
Ldg1PsetCconditionalCormat7HcommentsH&H64WH&array7HconditionHMPHcnH&
HvalueHMPHre.uestH&
HcssHMParray7HcolorHMPHwhiteH&Hbackground1colorHMPH]+?Z@D@H888E
set(data!ar*, ?
* Please note this feature is not available in Lite and asic versions.
Parameters!
<col(name: 2ame o column to display data bar. It should be numeric type
<color! Data bar color
escription!
9reates a data bar with gradient eect on a speciied column. 0or complex data
visuali:ation& "#" 9hart is highly recommended.
Remar;:
0or complex data visuali:ation& we recommend phpGrid sister product& "#" 9hart& a
highly customi:able "#" charting solution.
E0ample!
,Ldg 1P setCdatabar7Hpercent9ompleteH&HredH8E
set(conditional(value*, ?
* Please note this feature is not available in Lite and asic versions.
Parameters!
<col(name: 2ame o the column. Its value is used as the let operand or comparison.
<condition! comparison condition that compares given let and rigth hand operand with
comparison operator . e.g. > P ,J =E > M YabcR>E > QM true > etc.
<%ormatoptions: an array stores 9)) style ormat options. 'he value can be text&
#'(L& or even 9)) class. )ee example.
%$ell4alue! value to display when condition is 'rue
($ell4alue! value to display when condition is 0alse
escription!
It ormats and displays value in a cell when speciied condition is met. Fou can think it
as a simpliied version to setCconditionalCormat78 method.
Remar;!
'he condition is not =stackable> or a single column. In other words& only one condition
can be applied to any giving column.
E0ample!
2ote that tstyle and style are 9)) styles used as the ormatoptions.
,
?
%
+
$
<
@
A
.tstyle
^
display!blockEbackground1image!noneEmargin1right!1?pxEmargin1let!1
?pxEheight!,+pxEpadding!$pxEbackground1color!greenEcolor!navyEont1weight!bold
_
.style
^
display!blockEbackground1image!noneEmargin1right!1?pxEmargin1let!1
?pxEheight!,+pxEpadding!$pxEbackground1color!yellowEcolor!navy
_
"#" 9ode
,
?
%
+
$
<
@
Ldg1PsetCconditionalCvalue7His9losedH& HMM,H& array7
H'9ellGalueHMPHWimg srcMH)ampleImages-checked.giH altMHH -PH&
H09ellGalueHMPHWimg srcMH)ampleImages-unchecked.giH altMHH -PH88E
Ldg1PsetCconditionalCvalue7HstatusH& HMMB9ompleteBH& array7
H'9ell)tyleHMPHtstyleH&
H09ell)tyleHMPHstyleH88E
ena!le(autowidth*,
Parameters!
<autowidth: true or alse
escription!
3se this method to set datagrid width as the same as the current window width.
Automatically resi:es based on window width 7verison <N8
E0ample!
,Ldg 1P enableCautowidth7true8E
get(display*,
Parameters!
<add(script(includeonce: true or alse. Whether or not to include script header.
escription!
It returns the grid body with options to include script header. It is useul or (G9
ramework integration such as SoomlaQ and Drupal.
Remar;:
'he getCdisplay78 unction should be called A0'D6 display78 is called so that the grid
body and header is saved to an internal output buer that can be later retrieved by
getCdisplay78.
Dxample!
,
?
%
+
$
<
@
A
Z
Ldg M new 9CDataGrid7H)DLD9' I 064( ordersH& Horder2umberH& HordersH8E
Ldg 1P display7alse8E -- do not render display
Lgrid M Ldg 1P getCdisplay7alse8E -- do not include re.uired 5avascript libraries until later with with
displayCscriptCincludeonce method.
-- other page content goes here
-I ........................... I-
Ldg 1P displayCscriptCincludeonce78E
echo LgridE
ena!le(;!(nav*, C !eta
Parameters!
<is(ena!led: true or alse
escription!
Dnable navigation by keyboard using up and down arrow keys.
Remar;:
'his is a beta eature currently. 2ot recommended using it in production.
E0ample!
,Ldg1PenableCkbCnav7true8E
set(%orm(dimension*,
Parameters!
<%(width: orm width. 'he deault value is R+JJpxR
<%(height! orm height. 'he deault is 1, so it is automatically ad5usted to number o
rows.
escription!
)et edit 046( width and height during edit.
Remar;:
'he deault <%(height value is D8 7negative one8 so it is automatically ad5usted to
number o rows.
E0ample!
,
Ldg1
PsetCormCdimension7B$JJpxB8E
set$all5ac;
Parameters!
<call!ac;(str: callback string
escription!
3sed or pass setting between %rd party system and phpGrid using ASA/ callback. 6ead
the comments in ile callbac&str.php or usage
set(col(wysiwyg*,
* only available in Professional and above.
Parameters!
<col(name: column name
escription!
'urns simple text ield into word processor by replacing textarea with rich text editor.
)hould only be used or text ields that allows large amount o text such as notes and
comment ields.
Remar;:
'he ield must be a text data type. I not& use setCcolCedittype and set edit type to
=textarea> irst.
E0ample!
,
?
-- comments is text data type
Ldg1
PsetCcolCwysiwyg7BcommentsB8E
,
?
-- news is not a text data type
Ldg1PsetCcolCedittype7BnewsB& BtextareaB81
PsetCcolCwysiwyg7BnewsB8E
Fou can set its width height using setCcolCeditCdimension method.
set(col(de%ault*,
Parameters!
<col(name: column name
<de%ault: column deault value
escription!
)et column deault value 'his option is only valid or 0orm Dditing when adding a new
record. 3ser can override this entry.
E0ample!
,
Ldg 1P setCcolCdeault7BdirectionB&
BtopB8E
set(col(%ileupload*, ?
* Please note this feature is currently only available for Enterprise and Universal licenses.
Parameters!
<col(name! column name that stores ile name
<!ase(url! base 36L to the iles
<physical(path! speciy physical path to the older where the iles are uploaded. When
"#" is installed as Apache module& this parameter is optional.
escription!
'he ile upload is seamlessly integrated with the edit orm using A5ax& no page reresh
ever occurred. 0iles can be uploaded and deleted right within the orm.
Remar;!
A single ile upload per datagrid is allowed.
046( edit mode only
0ile system only with valid uploadCtmpCdir value in php.ini
0ile name column should allow 23LL value
LphysicalCpath is automatically obtained i "#" running in Apache module& or (3)'
be provided as allback
E0ample!
,
?
%
+
Ldg 1P setCcolCileupload7Hile'o3ploadH& H-phpGridx-0ile3pload0older-H&
Hc!\\xampp\www\\phpGridx\\0ile3pload0older\\H8E
-- i "#" is installed as Apache module& the %rd parameter& LphysicalCpath& can be ignored
Ldg 1P setCcolCileupload7Hile'o3ploadH& H-phpGridx-0ile3pload0older-H8E
set(col(date*,
Parameters!
<col(name! column name
<src%ormat! source date ormat& eg. =F1m1d>
<new%ormat! new date orm to be displayed& eg. =n-5-F>
<datepic;erCormat! datepicker ormat& eg. =m-dd-yy>
escription!
#elper unction to ormat date using "#" date ormat options
7http!--php.net-manual-en-unction.date.php8
Remar;!
In most cases& you donRt need to call this method because phpGrid automatically ormats
the data with corresponding data type including date.
4nly use this method in order to display date ormat that is dierent rom deault date
ormat.
'o display time only& please use setCcolCproperty instead.
E0ample!
,
?
%
+
-- src0ormat! (y).l date ormat is HF1m1dH
-- new0ormat! Display date ormat is Hn-5-FH
-- datepicker! Datepicker date ormat is Hyy1mm1ddH
Ldg 1P setCcolCdate7HorderDateH& HF1m1dH& Hn-5-FH& Hyy1mm1ddH8E
set(col(edit(dimension
Parameters!
<col(name! column name
<si@e4<cols: I the column is a text box& itRs the si@e that represents number o
characters. I the column is a textarea& itRs the value or cols attribute in textarea.
<rows: 4ptional. 2umber o rows in a textarea
escription!
)et input text box si:e or textarea cols and rows values in edit orm.
Remar;!
'o set dimension or entire edit orm& use setCormCdimension78
E0ample!
,
?
%
+
$
-- status is a text ields& +J indicates the text ield is +J characters long.
Ldg 1P setCcolCeditCdimension7HstatusH& +J8E
-- comments& a text data type& is rendered as textarea with cols set to $J& rows set to
,J
Ldg 1P setCcolCeditCdimension7HcommentsH& $J& ,J8E
set(col(property*,
Parameters!
<col(name! column name
<property: An array represents the column properties. List o available properties
7http!--www.trirand.com-5.gridwiki-doku.phpKidMwiki!colmodelCoptions8
escription!
'his method allows you to directly manipulate column properties. )ince column
properties are an array& you can directly change the properties. 'his is more =closer to
the metal> or users who are already amiliar with 5.Grid col(del A"I.
Remar;!
'his is an advanced method. In most cases& you donRt need to call this method. It does
not replace existing helper unctions such as setCcolCdate& setCcolCcurrency& etc. We
suggest you use those helper unctions i you are new to phpGrid.
'his method is also used to create custom ormatter. )ee a custom ormatter example
using this method.
E0ample!
,
?
%
+
$
<
@
Ldg 1P setCcolCproperty7Horder2umberH& array7HnameHMPH4rder 2umberH& HwidthHMP+J88E
Ldg 1P setCcolCproperty7HorderDateH&
array7HormatterHMPHdateH&
HormatoptionsHMParray7HsrcormatHMPHF1m1dH&HnewormatHMPHm-d-FH888E --
display dierent time ormat
Ldg 1P setCcolCproperty7HshippedDateH&
array7HormatterHMPHdateH&
HormatoptionsHMParray7HsrcormatHMPHI)4A<J,)hortH&HnewormatHMPHg!i AH888E --
display time only
add(event*,
Parameter7s8!
Levent(name! Dvent name rom one o the ollowing available events
5.Grid6esi:e)tart
5.Grid6esi:e)top
5.GridAterInsert6ow
5.GridGrid9omplete
5.GridAterGrid9omplete
5.Grid;eore6e.uest
5.GridLoad9omplete
5.GridAterLoad9omplete
5.Grid)ort9ol
5.Grid)electAll
5.Grid;eore)elect6ow
5.Grid9ell)elect
5.GridDbl9lick6ow
5.Grid6ight9lick6ow
5.Grid#eader9lick
5.Grid)elect6ow
5.Grid)how#ide9ol
5.Grid6emap9olumns
5.GridOeyLet
5.GridOey6ight
5.GridOeyDnter
5.GridOey)pace
5.Grid'oolbar;eore)earch
reloadGrid
5.Grid'oolbarAter)earch
5.Grid'oolbar;eore9lear
5.Grid'oolbarAter9lear
5.Grid0ilter;eore)how
5.Grid0ilterAter)how
5.Grid0ilterInitiali:e
5.Grid0ilter)earch
5.Grid0ilter6eset
5.GridAddDdit;eore9heckGalues
5.GridAddDdit9lick)ubmit
5.GridAddDdit;eore)ubmit
5.GridAddDditDrror'ext0ormat
5.GridAddDditAter)ubmit
5.GridAddDditAter9omplete
5.GridAddDdit;eoreInitData
5.GridAddDdit;eore)how0orm
5.GridAddDditAter)how0orm
5.GridAddDditInitiali:e0orm
5.GridAddDdit9lick"g;uttons
5.GridAddDditAter9lick"g;uttons
5.GridInlineDdit6ow
5.GridInlineAter)ave6ow
5.GridInline)uccess)ave6ow
5.GridInlineDrror)ave6ow
5.GridInlineAter6estore6ow
5.Grid;eoreDdit9ell
5.GridAterDdit9ell
5.Grid)elect9ell
5.Grid;eore)ave9ell
5.Grid;eore)ubmit9ell
5.GridAter)ubmit9ell
5.GridAter)ave9ell
5.GridDrror9ell
5.GridAter6estore9ell
5.Grid)ubGrid;eoreDxpand
5.Grid)ubGrid6owDxpanded
5.Grid)ubGrid6ow9olapsed
5.GridGrouping9lickGroup
5.GridImport9omplete
L#s(event(handler! Sava)cript event handler to the speciied event
escription!
9ustom event handler. A list o supported events!
http!--www.trirand.com-5.gridwiki-doku.phpK
idMwiki!events]listCoCtriggeredCeventsCnewCinCv+.%.?
Remar;!
'his is an advanced method. 'he event handler is Sava)cript.
E0ample!
http!--phpgrid.com-example-custom1event1handler-
display(script(includeonce*,
Parameter*s,:
2one
escription:
Includes re.uired Savascript libraries beore displaying our grids.
Remar;:
Developers donRt need to call this method to include re.uired Savascript libraries
75.Grid& 5wysiwyg& a5axilupload etc.8 because the phpGrid includes those Savascript
automatically or you. 'his method is only used in getCdisplay78 in a (G9 ramework.
add(column*,
Parameter*s,!
<col(name: 2ame o the calculated-virtual column. It cannot have space and must 24'
be one o the existing database column names.
<property! 9olumn properties. )ee setCcolCproperty78 or available column properties
usage.
<title! 4ptional. 'itle or this virtual column. I omitted& itRs the same as the column
name LcolCname.
escription!
Append virtual column& AOA calculated column& to the end o an existing datagrid with
this method.
Remar;!
'he LcolCname cannot contain space and must begin with a letter
3se =ormatter> column property to hook up Savascript unction& e.g. below&
LcolCormatter is the Savascript to display value in virtual column.
'he virtual column always adds to the end o the grid in the order o virtual column is
created.
'ext must be surrounded with )I2GLD .uote.
Girtual column is not sortable.
E0ample!
,
?
%
+
$
<
@
A
Z
,J
,,
,?
,%
,+
LcolCormatter M WWW94L046(A''D6
unction7cellvalue& options& row4b5ect8^
var n, M parseInt7row4b5ect`Ja&,J8& -- get value rom column
],
n? M parseInt7row4b5ect`<a&,J8E -- get value rom column ]@
return n,Nn?E
_
94L046(A''D6E
Ldg 1P addCcolumn7
BtotalB&
array7BnameBMPBtotalB&
BindexBMPBtotalB&
BwidthBMPB%<JB&
,$
,<
BalignBMPBrightB&
BormatterBMPLcolCormatter8&
B'otal 7Girtual8B8E
set(col(customrule*,
Parameters!
<col(name: column name
<custom rule: Savascript unction to validate data
escription!
9reate custom 5avascript validation or column value during edit. phpGrid has automatic
deault validation based on database data type. 'his method comes in handy when
additional data validation is re.uired such as value range& data dependency etc.
E0ample!
,
?
-- priceCvalidation, is a 5avascript unction. )ee related associate live example or complete
implementation
Ldg1PsetCcolCcustomrule7B.uantityIn)tockB& BpriceCvalidation,B8E
set(col(%ro@en*,
Parameter*s,:
<col(name! 9olumn name
escription:
)imilar to Dxcel column ree:e& phpGrid can now ree:e column7s8
Remar;!
2ote that the ro:en columns should be rom let to right& one ater other.
In inline edit& the ro:en columns are not editable.
9olumns are not draggable i any column is ro:en
E0ample:
,
?
-- ree:e both customerCid and customerCname columns
Ldg 1P setCcolCro:en7HcustomerCidH81
PsetCcolCro:en7HcustomerCnameH8!
set(grid(method*,
Parameter*s,:
parameter! A variable argument. Gariable argument makes the unction more lexible
because dierent 5.Grid methods will have dierent set o parameters. )uper useul.
escription:
9alling a 5.Grid method to perorm a speciic action on the current grid. It is considered
an advanced method.
A list o basic methods can be ound here! http!--www.trirand.com-5.gridwiki-doku.phpK
idMwiki!methods
6emark!
Available in $.$.$ and higher.
)tarting version <& the parameter becomes a single variable argument.
4nly use this method to call 5.Grid methods that can act on the grid as a whole. ItRs
24' possible to manipulate the grid on a row or cell level using setCgridCmethod
because the generated 5avascript code is appended to the end o the script beore closing
bracket.
E0ample:
,
?
%
+
$
<
@
A
Z
,J
,,
,?
,%
,+
-- create group header using this method
Ldg1PsetCgridCmethod7BsetGroup#eadersB& array7
array7Buse9ol)pan)tyleBMPtrue8&
Bgroup#eadersBMParray7
array7Bstart9olumn2ameBMPBcustomer2umberB&
Bnumber49olumnsBMP?&
Btitle'extBMPB2umbers #eaderB8 888E
-- inline edit add new row
Ldg1PsetCgridCmethod7Binline2avB&
B]B. Lthis1P5.Cgrid2ame .BCpager,B&
array7Badd"aramsB MP array7
BpositionBMP HlastH&
Badd6ow"aramsBMParray7
BkeysBMPtrue8888E
od!c(mssql
=odbcCmss.l> should only be used or D)2 connection or (icrosot )*L )erver in Inix or 4) /
operation system using unix4D;9 through 0ree'D) protocol. Fou can learn more about how to use
unix4D;9 with 0ree'D) here
uni0O5$
unix4D;9 re.uires additional environment variables in ile con.php
,
?
putenv7H4D;9I2)'I2IM-usr-local-9ellar-unixodbc-?.%.,-etc-odbcinst.iniH8
E
putenv7H4D;9I2IM-usr-local-9ellar-unixodbc-?.%.,-etc-odbc.iniH8E

BreeTS
0ree'D) uses a coniguration ile called =reetds.con>. ;elow is an sample o reetds.con used by
phpGrid during testing or your reerence.
,
?
%
+
$
<
@
A
Z
,J
-usr-local-9ellar-reetds-J.Z,-etc-reetds.con
] server speciic section
`globala
] 'D) protocol version
E tds version M +.?
] Whether to write a 'D)D3(" ile or diagnostic purposes
] 7setting this to -tmp is insecure on a multi1user system8
E dump ile M -tmp-reetds.log
,,
,?
,%
,+
,$
,<
,@
,A
,Z
?J
?,
??
?%
?+
?$
?<
?@
?A
?Z
%J
%,
%?
%%
%+
%$
%<
%@
%A
%Z
+J
+,
+?
+%
++
+$
+<
+@
E debug lags M Jx
] 9ommand and connection timeouts
E timeout M ,J
E connect timeout M ,J
] I you get out1o1memory errors& it may mean that your client
] is trying to allocate a huge buer or a 'D/' ield.
] 'ry setting Btext si:eB to a more reasonable limit
text si:e M <+$,?
`phpgridmss.la
host M phpgridmss.l.cbdlprkh5rmd.us1west1,.rds.ama:onaws.com
port M ,+%%
tds version M @.J
-usr-local-9ellar-unixodbc-?.%.,-etc-odbc.ini
`phpgridmss.la
Description M () )*L )erver
Driver M 0ree'D)
)erver M phpgridmss.l.cbdlprkh5rmd.us1west1,.rds.ama:onaws.com
'race0ile M -tmp-s.l.log
3ID M mss.luser
"WD M "A))W46D
6ead4nly M 2o
"ort M ,+%%
Database M sampledb
-usr-local-9ellar-unixodbc-?.%.,-etc-odbcinst.ini
`0ree'D)a
Description M 0ree'D)
Driver M -usr-local-9ellar-reetds-J.Z,-lib-libtdsodbc.so
)etup M -usr-local-9ellar-reetds-J.Z,-lib-libtdsodbc.so
0ile3sage M ,
9"'imeout M
9"6esuse M
client charset M ut1A
!e%ore(script(end
beoreCscriptCend is not a unction but a variable. It allows you to in5ect custom 5avascript beore the
end o 5.Grid ob5ect closing script tag so all D4( elements are presented. 'his is considered an
advanced way to manipulate your grid.
'he ollowing code snippet demonstrates using this variable to insert a 5avascript that creates a export
dropdown menu on the bottom toolbar.
,
?
%
Ldg% M new 9CDataGrid7H)DLD9' I 064( productsH& Hproduct9odeH& HproductsH8E
LexportDropdown MWWW D/"46'D64"D4W2
+
$
<
@
A
Z
,J
,,
,?
,%
,+
,$
L7B]productsCpager,CletB8.append 7BWdiv styleMpadding1right! ,<pxEPDxport!\
Wselect onchangeMdocument.location.hreMthis.options`this.selectedIndexa.valueEP\
WoptionP111W-optionP\
Woption valueM-phpGridx-export.phpKgnMproductsTexportCtypeMexcelPDxcelW-optionP\
Woption valueM-phpGridx-export.phpKgnMproductsTexportCtypeMpdP"D0W-optionP\
Woption valueM-phpGridx-export.phpK
gnMproductsTexportCtypeMhtmlP#'(LW-optionP\
Woption valueM-phpGridx-export.phpKgnMproductsTexportCtypeMcsvP9)GW-optionP\
W-selectPW-divPB8E
D/"46'D64"D4W2E
Ldg1PbeoreCscriptCend M LexportDropdownE
Ldg1Pdisplay78E
cust(prop(#sonstr
custoCpropC5sonstr is a variable& not a unction. 'he variable type is S)42)tring 7string in S)42
ormat8.
'he dierence between custCpropC5sonstr and setCgridCproperty78 is that the later is a unction and
must take an array as parameter. 4n the other hand& custCpropC5sonstr gives user the power to in5ect
string directly into the 5*grid properties.
>hich one to useE
'he rule o thumb is to use custCpropC5sonstr when the property is orm o stringE else use
setCgridCproperty78 unction. In general& you want to use setCgridCproperty78.
Remar;:
'his is an advanced variable. In most cases& you do not need to use it unless you are already very
amiliar with 5*grid in and out that you want to manipulate your grid properties like a code nin5a. !8
Dxample!
,
?
%
+
$
-- #ere ilters must be passed as string to data.php later sent through "4)'. ItBs not possible to use
setCgridCproperty unction which must take array params
Ldg1PcustCpropC5sonstr M BpostData! ^ilters!
\B^Hgroup4pH!HA2DH&HrulesH!`^HieldH!HstatusH&HopH!He.H&HdataH!H)hippedH_a_\B_&BE
-- add toolbar to top o the grid.
Ldg1PcustCpropC5sonstr M Btoppager!true&BE
set(grid(property*,
Parameters!
<grid(property! An array represents grid property. 'he property will add to or overwrite
existing "#" data grid properties. List o available grid properties
7http!--www.trirand.com-5.gridwiki-doku.phpKidMwiki!options8
escription!
Advanced method that sets datagrid properties. 'he parameter must be an array. Fou
must be rather amiliar 5.Grid A"I in order to take advantage o this method eectively.
In most cases& you do not need to use this method.
Remar;!
'his method is completely dierence rom setCcolCproperty78 method that sets column
property& a subset o grid property.
'his is an advanced method. In most cases& you donRt need to call this method.
E0ample!
,
?
%
Ldg 1P setCgridCproperty7array7BsearchBMPtrue88E
Ldg 1P setCgridCproperty7array7BdirectionBMPBrtlB88E
Ldg 1P setCgridCproperty7array7HaltclassH MP
HalternatieCrowCcssCclassH88E
custo(prop(#sonstr or set(grid(propertyE
'he dierence between custCpropC5sonstr and setCgridCproperty is that the later is a unction and must
take an array as parameter but custCpropC5sonstr takes string parameter.
>hich one to useE
'he rule o thumb is to use custCpropC5sonstr when the property is orm o stringE else use
setCgridCproperty78 unction. In general& you want to use setCgridCproperty78.
set(edit(condition*,
Parameters!
<edit(conditoin! An array stores edit permission condition.
escription!
)et row1level permission condition or editing.
Remar;!
'his works or I2LI2D 42LF by hiding the edit icons using 5avascript& 9))
0or that reason& developers should still validate user permission at the database or on the
server side.
0or complex conditions& use addCevent and 5avascript. )ee row1level edit permission
example.
E0ample!
,
?
Ldg 1P enableCedit7BI2LI2DB& B963DB8E
Ldg 1P setCeditCcondition7array7BstatusB MP BMMH)hippedHB& BTTB& Bcustomer2umberB MP
BMM,,+B 88E
'he above code snippet generates 5avascript that validates )tatus and customer2umber value. I both
are true& the edit icon will appear.
E5=" glo!al constant
Note: DEU! global constant is only available starting version -. (or php!rid version 5.5.5 and
lo1er' see enable*debug23 method please.
phpGrid version < introduces a new global constant named =DD;3G> in con.php. When set to true& it
turns on the debug mode. When not deined& DD;3G value deaults to alse.
>hen E5=" set to true:
When set to true& it displays phpGrid ob5ect as well as the current "#" session inormation. In
addition& ASA/ response data are also displayed during 963D operations. 'his is helpul
debugging inormation can be used during development.

It also display the phpGrid version number and associated 5avascript libraries used.
,
?
-- In con.php
deine7BDD;3GB& true8E
T'E1E glo!al constant
Available starting phpGrid version <& you can set a global constant =T'E1E> in con.php to change
all o your datagrid themes without calling setCtheme78 method individually.
,
?
-- set a global theme in con.php 7version
<N8
deine7B'#D(DB& BcobaltB8E
'he premium themes are currently available to Dnterprise and 3niversal Licenses.
set(sorta!lerow*,
Parameters!
<sorta!le! true or alse
escription!
Activate sortable row. Drag and drop row to sort.

Remar;!
'he sort does not persist. 'he sort is lost the grid or the page rereshes.
E0ample!
,Ldg 1P setCsortablerow7true8E
ena!le(columnchooser*,
Parameters!
<ena!le! true or alse
escription!
Dnable column chooser.

Remar;!
'he column chooser does not persist. 'he columns displayed resets whenever grid or the
page rereshes.
E0ample!
,
Ldg 1P
enableCcholumnchooser7true8E
ena!le(autoheight*,
Parameters!
<autoheight: true or alse. Deault to alse.
escription!
3se this method to set datagrid height as the same as the current window height.
Remar;!
Do not use this method when multiple grids present on a single page
E0ample!
,
Ldg 1P
enableCautoheight7true8E

E0amples: "etting Started
Introduction
A ;asic "#" Datagrid
E0amples: atagrid Properties
Datagrid 9aption
Datagrid "agination
Interactive Grid 6esi:ing
Enter search keywords...
E0amples: "rid Editing
Dditable Datagrid I
)elect (ultiple 6ecords
)et Ddit #'(L 9ontrol
(ultiple "#" Dditable Datagrid
9ustomi:e Ddit 0orm Layout
Inline Ddit Actions 9olumn
6ow1level Ddit "ermission
9omposite "rimary Oey )upport I
E0amples: $olumn Properties
Descriptive 9olumn #eaders
#ide 9olumn
)et #eight and Width
Display #yperlink
Display Dynamic 36L
Data 0ormat Display
Image Display
6ead only ields
6e.uired ields
#yperlink to 9all Sava)cript 0unction
9olumn 0ree:e
E0amples: 1aster etail
(aster Detail Grid I
)ubgrid
(aster with (ultiple Detail Grids I
2ested (aster Detail Datagrid I
E0amples: Search F E0port
Dxcel& #'(L& "D0& or 9)G Dxport
Integrated )earch
Advanced )earch
beoreCscriptCend
E0amples: =I. ata F "rouping
Load Data with Gertical )croll
'heme 6oller I
9olumn Grouping with )ummary I
9reate Dxcel1Like Grid
#ori:ontal )croll
9olumn (ethods
(ultiple Datagrid Instances 0rom the )ame 'able
9olumn 9hooser T )ortable 6ow
E0amples: Boreign $haracters
Locale )etting
Display 2on1Dnglish 9haracters
E0amples: $onditional Output
9onditional Galue I
9onditional 0ormat I
E0amples: Advanced 1ethods
Girtual-9alculated 9olumn
9ustom Dvent #andler
9ustom Data Galidation
9olumn "roperty
9olumn (ethods
Integrated A#a0 Bile =pload
"#" Datagrid ASA/ 0ile 3pload
Integration
phpGrid& php9hart Integration
php"rid ocumentations
)ystem 6e.uirements
'echnical 4verview
Installation
phpGrid 9onstructor
setC.ueryCilter7LW#D6D8
enableCedit78 I
enableCexport78
enableCresi:e78
display78
enableCdebug78
enableCsearch78
setCcaption78
setCcolCcurrency78
setCcolCdynalink78
setCcolCedittype78
setCcolCormat78
setCcolChidden78
setCcolCimg78
setCcolClink78
setCcolCreadonly78
setCcolCre.uired78
setCcolCtitle78
setCdimension78
setC5.Cdatatype78
setC5.Cediturl78
setC5.Cgrid2ame78
setCmasterdetail78 I
setCmultiselect78
setCpagesi:e78
setCrowCcolor78
setCscroll78
setCsortname78
setCsubgrid78
setCtheme78
setCcolCwidth78
setCgroupCproperties78 I
setCgroupCsummary78 I
enableCrownumbers78
setCcolCalign78
enableCadvancedCsearch78
setClocale78
setCconditionalCormat78 I
setCdatabar78 I
setCconditionalCvalue78 I
enableCautowidth78
getCdisplay78
enableCkbCnav78 U beta
setCormCdimension78
set9all;ack
setCcolCwysiwyg78
setCcolCdeault78
setCcolCileupload78 I
setCcolCdate78
setCcolCeditCdimension
setCcolCproperty78
addCevent78
displayCscriptCincludeonce78
addCcolumn78
setCcolCcustomrule78
setCcolCro:en78
setCgridCmethod78
odbcCmss.l
beoreCscriptCend
custCpropC5sonstr
setCgridCproperty78
setCeditCcondition78
DD;3G global constant
'#D(D global constant
setCsortablerow78
enableCcolumnchooser78
enableCautoheight78
b ?J,+ phpGrid. All 6ights 6eserved.
'erms T 9onditions c "rivacy "olicy c Ailiate "rogram

Potrebbero piacerti anche