预定义的格式化类型

下表列出了jqGrid中的预定义格式化类型:
formatoptions配置的项依据formattype来确定。

 类型 选项(默认值参考语言选项)描述 
 integerthousandsSeparator,
defaulValue
  1.  thousandsSeparator:指定千位分隔符号
  2. defaultValue :指定数据为空时默认显示的值
 numberdecimalSeparator,
thousandsSeparator,
decimalPlaces,
defaulValue
  1.  decimalSeparator :指定小数分隔符
  2. thousandsSeparator:指定千位分隔符号
  3. decimalPlaces:指定需要显示多少个小数位
  4. defaultValue :指定数据为空时默认显示的值
 currency decimalSeparator,
thousandsSeparator,
decimalPlaces,
defaulValue,
prefix,
suffix
 和number一样,知识多了2个选项
  1. prefix:数字前面显示的文本内容
  2. suffix:数字后显示的文本内容
 date srcformat,
newformat,
parseRe
  1.  srcformat :源格式,应该被转换成的日期格式【就是将数据源中的原始格式转为这个定义的格式】
  2. newformat: 输出格式,使用PHP的日期格式化参数,也可以使用预定义好的日期格式,查看默认值参考语言选项配置中的date-》masks配置。
  3. parseRe:一个解析日期字符串的表达式
 email none 设置email将会给内容添加链接,链接地址为mailto:emai内容
 link target target 默认值为null。设置为这个,会构造一个连接,添加target属性,单元格内容作为href属性值
 showlink baseLinkUrl,
showAction,
addParam,
target,
idName
  1.  baseLinkUrl:链接地址
  2. showAction:添加到 baseLinkUrl后的附加值
  3. addParam:添加到idName属性后的附加参数
  4. target:链接在哪个窗口打开,给链接添加target属性
  5. idName:showAction后第一个被添加的参数,默认值为“id"
 checkbox disabled disabled默认值为true。控制checkbox是否能被改变。设置为false,可以膝盖checkbox的值。
 select none 不是真实的select,仅为一个特例,看下面的说明
 actions {
keys: false,
editbutton : true,
delbutton : true,
editformbutton: false,
onEdit : null,
onSuccess: null,
afterSave:null,
onError: null,
afterRestore: null,
extraparam: {oper:'edit'},
url: null,
delOptions: {},
editOptions : {}
}
  1. 在行编辑模式这个类型的格式化函数很容易给指定的列添加一个按钮。
  2. 有2中类型的动作,编辑和删除。
  3. editformbutton设置为true 将使用表单编辑对话框,取代行编辑模式
  4. editOptions仅用于配置表单编辑模式

"Select"格式化函数

select类型不是真实的select。这个用于使用某些编辑模式下,设置了edittype:'select'的情况。这个版本之前grid显示select的值,而不是键,例如:

jQuery("#grid_id").jqGrid({
   ...
   colModel : [ {name:'myname', edittype:'select', editoptions:        
    {value:"1:One;2:Two"}} ... ],
    ...
});

这个情况下,grid的数据需要包含"One"或者"Two",设在myname这个列里面。配置formatter为select的代码如下

jQuery("#grid_id").jqGrid({
...
   colModel : [ {name:'myname', edittype:'select', formatter:'select', editoptions:{value:"1:One;2:Two"}} ... ]
...
});

数据包含键名称(“1” or “2”),但是值 (“One”, or “Two”) 将会显示在grid里面。

showlink 示例

jQuery("#grid_id").jqGrid({
...
   colModel: [ {name:'myname', formatter:'showlink', formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}, ...} 
      ... 
   ]
...
});

上面将会得到下面的输出

http://localhost/someurl.php?id=123&action=edit

如果你想将生成的url中id键名称修改为myid,可以这样设置
 

jQuery("#grid_id").jqGrid({
...
   colModel: [ {name:'myname', formatter:'showlink', formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit', idName:'myid'}, ...} 
      ... 
   ]
...
});


http://localhost/someurl.php?myid=123&action=edit

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值