jqgird 加 Datepicker 小测试

先说下自己的项目需求,就是需要在表格生成后点击单元格要出现日期选择器,我使用的是jquery自己的Datepicker,其他日期插件使用方法大同小异(主要是在日期插件配置上不同)

示例图

引入插件的步骤这里就不讲了,相信用到这几个插件的小伙伴都知道怎么做。

步骤: 1.要将相应列的 editable 属性设为 true

$("#grid").jqGrid({  
                url : //数据链接url,  
                datatype : "json",  
                mtype : "GET",  
                colNames : [ "uuid", "名称", "生产日期" ,"备注"],  
                colModel : [ {  
                    name : "uuid",  
                    index : "uuid",  
                    width : "130",  
                    hidden : true  
                }, {  
                    name : "name",  
                    index : "name",  
                    width : "130",  
                    editable : true  
                }, {  
                    name : "fromDate",  
                    index : "fromDate",  
                    width : "130",  
                    editable : true  
                },{  
                    name : "remark",  
                    index : "remark",  
                    width : "130",  
                    editable : true,  
                } ],  
                rowList : [ 10, 20, 50, 100, 200 ],  
                rowId : "uuid",  
                pager : "#pager",  
                sortname : "name",  
                recordpos : "right",  
                viewrecords : true,  
                sortorder : "asc",  
                multiselect : false,  
                autowidth : true,  
                height : "auto",  
                multiselect : true,  
                jsonReader : {  
                    root : "dataList",  
                    total : "totalPages",  
                    page : "currentPage",  
                    records : "totalRows",  
                    repeatitems : false  
                },  
                sortable : false,  
                cellEdit : true,// 表示表格可编辑  
                cellsubmit : "clientArray", // 表示在本地进行修改  
                afterEditCell : function(rowid, cellname, value, iRow, iCol) { 
                   var cellId = iRow + "_" + cellname; 
                   $("#" + cellId).datepicker({ dateFormat: "yy-mm-dd" });  
                }  
            });  

2 在aferEditCell 方法后面加上插件

afterEditCell : function(rowid, cellname, value, iRow, iCol) { 
                   var cellId = iRow + "_" + cellname; 
                   $("#" + cellId).datepicker({ dateFormat: "yy-mm-dd" });  
                }  

之后再点击生产日期列 下面的单元格时就可以出现日期选择器了。

转载于:https://my.oschina.net/u/1036767/blog/713589

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值