上一章已經說明了在jqgrid中如何對資料分組,這一章主要**如何格式化jqgrid中的資料。何謂格式化呢?舉個例子,比如對時間格式化處理,去掉後面的時分秒;對數字進行處理,加上千分位分隔符,小數的保留位數,加上字首或字尾。對超連結或郵箱等等。
jqgrid中對列表cell屬性格式化設定主要通過colmodel中formatter、formatoptions來設定的。jqgrid中也預定義了常見的格式及其options屬性。
formatter
formatoptions
integer
thousandsseparator://千分位分隔符, 如」,」
defaulvalue://預設值
currency
decimalseparator: //小數分隔符,如」.」
thousandsseparator: //千分位分隔符,如」,」
decimalplaces: //小數保留位數
defaulvalue:
prefix://字首,如加上」$」
suffix://字尾
number
decimalseparator: //小數分隔符,如」.」
thousandsseparator: //千分位分隔符,如」,」
decimalplaces: //小數保留位數
defaulvalue:
date
srcformat, //原來的格式 newformat //新格式
select
沒有引數,使用方法如: editoptions:}
checkbox
disabled:true or false
showlink
baselinkurl://在當前cell中加入link的url
showaction://在baselinkurl後加入&action=actionname
addparam://引數,如」&name=xx」
target:
idname:缺省會在baselinkurl後加入,如」.action?id=1″。如果 設定idname=」xx」,那麼」.action?xx=1″。取值為當前rowid
沒有引數
用法也比較簡單,在jqgrid的colmodel加入相應的formatter和formatoptions即可。如:12
3456
78910
1112
1314
,
如果預定義的格式化不能滿足你的要求,jqgrid還提供了自定義格式化資料的方式。語法為:12
3function
diyfmatter(cellvalue, options, rowobject)
對於自定義formatter,在修改時需要獲取原來的值,這裡就提供了unformat函式。如:12
3456
78910
然後自己寫自定義格式化的方法。如:12
3456
78function
diyformat( cellvalue, options, rowobject )
function
diyunformat( cellvalue, options, cell)
jqgrid入門-jqgrid格式化資料(九)
Jqgrid入門 Jqgrid列資料拖動 七
上一章提到在jqgrid中如何設定二級表頭,這一章節主要 jqgrid 裡面的資料如果實現拖動功能,比如你想把第一行的資料拖到當前頁的最後一行,或者其他位置。jqgrid 外掛程式自己沒有提供這種功能的,如果要使用這個功能,還需要匯入 jquery.tablednd.js 初始化拖動外掛程式 如 1...
jqgrid合併單元格
原文 根據這個的啟發 how to merge cells in jqgrid 4.0 參考這裡 jqgrid官方的事件和方法 5b 5d gridcomplete i doku.php?id wiki methods 才有了下邊的文章 有圖有真相 merger這個方法大家可以直接呼叫 裡邊都不用修...
jqgrid本地載入分頁 jqGrid 分頁
這兩天一直在搞jqgrid分頁,焦頭爛額,不過還是有點收穫的 主要是後台分頁 jqgrid分頁可以分為兩種,遠端資料 伺服器資料 分頁和本地資料分頁,先看遠端資料分頁 testgrid jqgrid else if pagebtn prev userlistpg else if pagebtn la...