jQgrid的文件說明

jQgrid的文件說明

1. Data returned from the server can be in XML or JSON

XML Syntax:
<?xml version ="1.0" encoding="utf-8"?>
<rows>
<page> </page>
<total> </total>
<records> </records> (new tag)
<row id = “unique_rowid”>
<cell> cellcontent </cell>
<cell> <![CDATA[<font color=”red”>cell</font> content]]> </cell>

</row>

</rows>

JSON Syntax:

{ total: xxx, page: yyy, records: zzz, rows: [
{id:”1″,cell:[”Row 1:1″,”Row 1:2″,”Row 1:3″,”Row 1:4″]},
{id:”2″,cell:[”Row 2:1″,”Row 2:2″,”Row 2:3″,”Row 2:4″]},
{id:”3″,cell:[”Row 3:1″,”Row 3:2″,”Row 3:3″,”Row 3:4″]},

]}

In page tag server must return the number of the requested page.
In total tag server must return the total pages of the query.
In records tag server can return the total records from the query.
In cell tag is the actual data. Note that CDATA can be used. This way we can add images, links and check boxes.

Actually the cell data in the grid is inserted as html and not as text.

In PHP script use the following code for page header (when using xml):

<?php
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml"); } else {
header("Content-type: text/xml");
}
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
?>

2. The selector in the html document must be a table element of class “scroll”. Example:

<table id= "table_id" class="scroll" cellpadding="0" cellspacing="0">
</table>

3. Parameters passed to the server url (you must use a get method to obtain the values) are:
page - the requested page;
rows - the number of the requested rows that server must return;
sidx - the name (or number) of the column in the ORDER BY clause;
sord - way in which the column must be sorted - asc (ascending) or desc (descending);

4. Parameters used when constucting the grid. Example:

var mygrid = $(”#table_id”).jqGrid( {
url: “myurl.php”,
height: 150,
page: 1,
colNames: [”colname1″,”colname2″],
colModel: [
{index : ‘col1′, width : 80, sortable : true, align: ‘left’},
{index : ‘col’, width : 80, sortable : true, align: ‘left’}
],
rowNum: 20,
rowList: [20,30,40,50],
pager: $(”#page_selector_id”),
sortorder: “asc”,
sortname: “”,
altRows: true,
sortascimg : “sort_asc.gif”,
sortdescimg : “sort_desc.gif”,
firstimg: “first.gif”,
previmg: “prev.gif”,
nextimg: “next.gif”,
lastimg: “last.gif”,
onSelectRow: function (iRow) { …},
onSortCol: function (idx,iCol){ …},
ondblClickRow: function (iRow) { … }
});

Description of the parameters:

url: (mandatory) - the url where the XML file resides or is constructed with SQL.
height: (optional) - the heght of the grid in pixels. Default 150.
page: (optional) - the requested page number. Default 1.
colNames: (mandatory) - array which describes the column names in the grid
colModel: (mandatory) - array which describes the parameters of the columns. The parameters are:

  • name: (optional) - the index name which is used when sorting the data. Alias name can be used - i.e mytable.mycol. If this parameter is not set a unique number is assign in the order in which apper in the array - i.e 1,2… .
  • width: (mandatory) - the initial width of the column in pixels. Note that the width of the grid is sum of all columns width + 20 pixels for the scrolling.
  • sortable: (optional) describes if the column can be sorted. Valid values are true or false. Default is true.
  • align: (optional) - This attribute specifies the horizontal alignment of the element. Posible values are: left, center, right. Default is left.
  • sorttype: (optional) - This attribute describes the type of the field. This is only used if datatype option is set to “local”, or when load at once method is used. The possible values are: int, float, date, text.

rowNum: (optional) the number of rows that must be returned from the server (query). Default is 20.
rowList: (optional) if set this parameter construct a select box element in the pager in wich the user can change the number of the visible rows. Default is empty array.
pager: (optional) this parameter describes the pager. This must be a valid html element. Example: $(”#mypager_id”). If the element is of class “scroll”, then the width is equal to the grid.
sortorder: (optional) sets the sorting order. Default asc (ascending)
sortname: (optional) sets the initial sorting column. Can be a name or number. Default is empty string.
altRows: (optional) set a zebra like table. Default true
sortascimg : and sortdescimg : (optional) these parameters are liks to image url which are used when the user sort a column.
firstimg: , previmg: , nextimg: , lastimg: (optional) these parameters are liks to image url which are used in the pager.
onSelectRow: (optional) raised immideatly after row was clicked. The input parameter of the function is the row_id. Default null.
onSortCol: (optional) raised immideatly after sortable column was clicked and before sorting the data. The input parameters of the function are the index name and column index. Default null.
ondblClickRow: (optional) raised immideatly after row was double clicked. The input parameter of the function is the row_id. Default null.
datatype: (optional). Default “xml”. Possible values “xml” or “json” or “local”. Set this option according to data type returned from the server. If set to “local” the grid expected to load data local via array.
width: (optional) Default: none. If this option is not set, the width of the grid is a sum of the width’s of the columns defined in the column model + 20 pixels. If this option is set the width of each column is scaled according to the defined width. Example: if we define two columns with a width of 80 and 120 pixels, but want the grid to have a 300 pixels - then the columns are recalculated as follow: 1- column = 300(new width)/200(sum of all width)*80(column width) = 120 and 2 column = 300/200*120 = 180.
rowheight: (optional) Default: null. This option defines the height of the single row ( must make some experiments here). If is set the height of the grid is changed according to the number of the returned rows from the server and the scroll bar does not appear. Important note here - if you want this to work you should not change the property overflow hidden and white-space nowrap in the CSS
viewrecords: (optional) Default: false. If you want to view the total records from the query in the pager bar you should set option to true. The related tag is: records in xml or json definitions.
recordtext: (optional) This displays a text after the viewed records. The default value is in English and is: Record(s).
imgpath: (optional) Default: empty string. Whit this option you can define the path to the images that are used from the grid. Define this without a “/” at the end.
loadtext: (optional) Default: “Loading…”. With this we can change the text which apper when requesting and sorting data.
loadonce: (optional) Default: false. If this flag is set to true, the grid load only once the data from the server. All other manipulations are done at client side. Note that in this case the pager is disabled.
multiselect: (optional) Default: false. If this flag is set to true a multi selection of rows is enabled. A new column at left side is added. This can be used with server and local data.
subGrid: (optional) Default: false. Is set to true this enables using of sub grid.
subGridUrl: (optional) Default: empty string. This option has effect only if subGrid option is set to true. This describes the url for the subgrid data. Additinally to this url is added parameter “id” which is the id of the row. If using PHP we can use $id = $_GET[’id’]; to obtain the needed information of the sub grid data.
subGridModel:(optional) Default: empty array. This option has effect only if subGrid option is set to true. This option describes the model of the subgrid. The syntax is as follow: subGridModel:[{ name : [’n1′,’n2′,..,’nN’],width : [w1,w2,…,wN] }] - where n1..nN are the names which appears at the header of the sub grid and w1..wN are the widths of the columns. See example page for using a sub grid.

5. Methods

After constructing the grid we can use the following methods.

getUrl - return the current url
getSortName - return the current sortname
getSortOrder - return the current sorting order
getSelectedRow - return the current selected row
getPage - return the curent page number
getRowNum - return the current number of requested rows
setUrl(’newurl’) - set a new url
setSortName(’newsortname’) set a new sort name
setSortOrder(’newsortorder’) set a new sort order
setPage(newpage) set a new page number
setRowNum (newrownum) set a new number of requested rows.
.trigger( ‘reloadGrid’) method reloads a data with the current settings.

New Methods

getMultiRow return a one dimensional array with the selected rows id’s. Can be used if the flag multiselect is set to true.
getDataType return the current data type. Possible values are : xml, json, local.
getRecords return the number of records in grid.
setDataType(newdatatype) Set a new data type. Possible values are : xml, json, local.
getRowData(rowid) Return associative array ([name:value,..])with the values of the requested rowid. If the row can not be found the method returns empty array.
delRowData(rowid) Deletes row with the id - rowid. Return true is the operation success, otherwise false.
setRowData(rowid, data) Updates the values (using data array) in the row with the given rowid. The syntax of data array is: {name1:value1,name2: value2…} where the name is the name of the column as described in the colModel and the value is the new value. Return true on success.
addRowData(rowid,data) Insert new row with id rowid at the end of the grid using data array.The syntax of data array is: {name1:value1,name2: value2…} where the name is the name of the column as described in the colModel and the value is the value. Return true on success.
toXmlData(encoding) Return a XML string with a current data in the grid. The default encoding is utf-8.
toJSONData() Return a string in JSON format with the current data in the grid.

If you want to set new parameters a reloadGrid method load a data with a new setting.
Example:
mygrid.setPage(5);
mygrid.trigger(’reloadGrid’);

where mygrid = $(”table_id”).jqGrid(…);

loads a Page 5 from the server

A simple PHP MySQL generation of the XML File can be found here


Host Networking on VirtualBox

參考 : http://b2d.tnc.edu.tw/phpBB2/viewtopic.php?t=2259

來自 : http://www.linuxweblog.com/virtualbox-host-networking

 

# VirtualBox Bridging

# load the tun module
modprobe tun

# Create a tap device with permission for the user running vbox
tunctl -t tap0 -u {user}
chmod 666 /dev/net/tun

# Bring up ethX and tapX in promiscuous mode
ifconfig eth0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc

# Create a new bridge and add the interfaces to the bridge.
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 tap0

# Give the bridge a dhcp address.
dhclient br0


Sucess: Subversion, apache2, SSL, ubuntu 7.10/8.04

 Sucess: Subversion, apache2, SSL, ubuntu 7.10/8.04, with users

http://linuxhappy.wordpress.com/2008/01/21/sucess-subversion-apache2-ssl-ubuntu-710-with-users/


eclipse 3.3 no swt-mozilla-gtk-3347 or swt-mozilla-gtk 錯誤

最近重裝 ubuntu 8.04 後,將原來的 eclipse 3.3 直接搬至新安裝的機器,開 css 檔案時出現錯誤

java.lang.UnsatisfiedLinkError: no swt-mozilla-gtk-3347 or swt-mozilla-gtk  ...

 找到解決的方法:

http://www.eclipse.org/swt/faq.php#whatisbrowser

 重裝  xulrunner套件就好了

  sudo apt-get install xulrunner


轉貼 HOWTO: smooth CVS to SVN migration (and back again)

This page explains how I migrated the VideoLAN CVS repositories to Subversion while still allowing anonymous CVS access for users who did not want to move to Subversion. If you are a CVS user and have not yet fallen in love with Subversion, I suggest you have a look at this excellent project. In fact, I recommend to be familiar with Subversion before reading this document, because I may have missed important things.

The idea is to migrate the CVS repository to a Subversion repository using cvs2svn, disable CVS accounts (except read-only accounts such as anonymous) and set up post-commit hooks to replicate SVN commits back to the CVS repository.

First step: cvs2svn

Here are the preparatory steps to migrate a CVS module wooyay from the CVS root /cvs/stuff to a new SVN repository /svn/wooyay:

$ svnadmin create /svn/wooyay
$ cvs2svn -s /svn/wooyay /cvs/stuff/wooyay
$ svn ls file:///svn/wooyay
branches/
tags/
trunk/
$

That’s all! Your SVN repository is created. The default layout is a bit special but quite handy: tags are in tags/, branches are in branches/, and HEAD is trunk.

Don’t forget to backup your old CVS tree! It might be useful if something ever gets wrong.

Repository cleaning

Now that your repository is created, you can use Subversion’s magical powers to do whatever you want to the repository, such as removing and renaming branches or tags. These steps are not mandatory but you might find them convenient.

CVS branch names cannot start with a digit or contain periods, and you end up with branches called v1_2_3 instead of 1.2.3. And I don’t like that. Here is an example of what I would do:

$ svn ls file:///svn/wooyay/branches
test/
v1_0/
v2_0/
$ svn rm file:///svn/wooyay/branches/test -m "removed branch"
$ svn mv file:///svn/wooyay/branches/v1_0 file:///svn/wooyay/branches/1.0 -m "renamed branch"
$ svn mv file:///svn/wooyay/branches/v2_0 file:///svn/wooyay/branches/2.0 -m "renamed branch"
$ svn ls file:///svn/wooyay/branches
1.0/
2.0/
$

I also like to import .cvsignore files to Subversion properties and set the "Id" keyword properties for files containing the "$Id:" special string. If your repository is big, you might want to do this change only for trunk/ and the still active branches.

$ svn checkout file:///svn/wooyay/trunk workingdir
$ cd workingdir/
$ find -name .cvsignore | while read file; do
    svn propset svn:ignore "`cat "$file"`" "`echo "$file" | sed 's,/[^/]*$,,'`"
  done

$ find . -type f -a '(' -path '*/.*' -prune -o -print ')' | while read file; do
    if grep -q '\$Id:' "$file" && ! svn propget svn:keywords "$file" | grep -q '^Id$'; then svn propset svn:keywords Id "$file"; fi
  done

$ svn commit -m "imported svn:ignore and svn:keywords properties"
$

The post-commit hook

This is the important part. My svn_cvsinject script can be used to reinject SVN commits into the old CVS directory. Use option -r to specify the revision to reinject, and -a to do branch aliases. In our example, this would be the contents of the /svn/wooyay/hooks/post-commit file:

#!/bin/sh
REPOS="$1"
REV="$2"
svn_maillog "$REPOS" "$REV" "svn@localhost" "sam@localhost"
svn_cvsinject -r "$REV" "$REPOS" "/cvs/stuff/wooyay" \
    -a "1.0/v1_0" -a "2.0/v2_0" &
exit 0

It is advisable to run svn_cvsinject in the background because it can take a long time to finish. Also, make sure that all users with commit rights (including the user svnserve might run as) have write permissions on the CVS repository.

Here are the current svn_cvsinject features:

  • support for file creation and removal
  • support for directory creation and removal
  • support for simultaneous commits in different branches
  • support for branch aliases

However, it also has the following current limitations:

  • no support for new branches
  • no user mapping when run from svnserve (but the user is mentioned in the commit log)
  • concurrent calls may break things (use locks)
  • poor error handling

Conclusion

It works for me (tm), but I’d be happy to learn of other successful installations. And please tell me of failures as well, so that I can fix bugs!

If your CVS repository ever gets corrupted, you can reinject every SVN commit by restoring your backuped CVS tree and calling svn_cvsinject again for every revision since you used cvs2svn


docbook 配合 自訂的 css 輸出

以 ubuntu 為例:

修改

/usr/share/sgml/docbook/stylesheet/dsssl/modular/html/docbook.dsl

...
(define all-element-number
(external-procedure "UNREGISTERED::James Clark//Procedure::all-element-number"))
; 從這開始
(define %stylesheet%
"docbook.css")

(define %stylesheet-type%
"text/css")
; 到這結束
(root
(make sequence ...
...

撰寫 docbook.css ,放在目標文件下

參考文件 :

http://www.powermag.com.tw/docbook/book1.htm


unable to load php_ldap.dll on php5.x

php_ldap.dll needs the following dlls:

ssleay32.dll
libeay32.dll

Copy them to the system32 directory.


20 pro tips

Tips and tricks you should be using to give your work that all-important professional edge.

http://www.netmag.co.uk/zine/design-tutorials/20-pro-tips


lifetype 使用者註冊問題

lifetype 對使用者的帳號採取較嚴格的限制,僅允許 A-Z a-z 0-9 的字元做為帳號,如要增加字元範圍可修改:
class/data/validator/usernamevalidator.class.php
define( "ONLY_ALPHANUMERIC_REGEXP","^([A-Za-z0-9]*)$" );


OPENLDAP 備份與還原

backup_ldap.sh 將每日 ldap 備份出來

#!/bin/bash

the_date=`date '+%m-%d-%y'`

the_dc='dc=tcc'

the_name=/var/ldap_backup/ldap_backup_$the_date.bz2

/usr/sbin/slapcat -f /etc/openldap/slapd.conf -b "$the_dc" | bzip2 -9 > $the_name

還原:

bzip2 -d /var/ldap_backup/ldap_backup_11-07-05.bz2

slapadd -c -l /var/ldap_backup/ldap_backup_11-07-05


利用 Web Editor 寫網誌

利用 Web Editor 寫網誌,參考網址

 http://plog.yejh.tc.edu.tw/index.php?op=ViewArticle&articleId=426&blogId=1  


FortiGate-400研習教材

bubble's weblog 的 FortiGate-400研習教材


PostgreSQL Performance Tips

取自:

http://chery.axonpro.sk/pgsql/chapters/performance/index.html

 (閱讀全文)


postgresql FAQ

http://sraapowergres.com/en/newsletter/issue_01/faq.inc.html (閱讀全文)


修改 pLog 認證方式記事

pLog 是個優秀的軟體,採用 MVC 設計理念,讓網頁展現的部份可以獨立出來,符合了 BLog 個人化的特性,plugin 的功能使得 BLog 附加的功能具彈性容易擴展。

但如要對特定 user 申請限制時,目前並沒有可用的方式,因此我自已修改了 pLog 認證的程式,可以讓申請者和台中縣網既有的 LDAP 帳號做整合。

 (閱讀全文)