如何在jqgrid中添加datepicker [英] how to add datepicker in jqgrid

查看:56
本文介绍了如何在jqgrid中添加datepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在网格中写入日期字段时,不显示我的网格日期字段.甚至网格也没有显示

In my grid date field is not displayed when I write the date field in grid. Even grid also not displayed

colModel:[
{name:'id',index:'id', width:55, editable:false,editrules:{required:true},searchoptions:{sopt: ['eq', 'ne']}},            
{name:'employe',index:'employe', width:100,editable:true,formoptions:{rowpos:2,elmprefix:"    "},editrules:{required:true}},
{name:'gender',index:'gender', width:55,editable: true, formatter: 'dynamicText', width: 150, edittype: 'custom', editoptions: { custom_element: radioelem, custom_value: radiovalue},formoptions:{rowpos:4,elmprefix:"    "}},
{name:'role',index:'role', width:100,editable:true,edittype:"select",
    editoptions:{dataUrl:'test.txt', defaultValue:'Intime'},
    formoptions:{rowpos:3,elmprefix:"    " }},
{name:'department',index:'department', width:80, align:"right",editable:true,edittype:"select",
    editoptions:{dataUrl:'test.txt', defaultValue:'Intime'},
    formoptions:{rowpos:5,elmprefix:"    " }},
{name:'joinedate',index:'joinedate', width:80,
    editable:true,
    editoptions:{size:12,
        dataInit:function(el){
            $(el).datepicker({dateFormat:'yy-mm-dd '});
        },
        defaultValue: function(){
            var currentTime = new Date();
            var month = parseInt(currentTime.getMonth() + 1);
            month = month <= 9 ? "0"+month : month;
            var day = currentTime.getDate();
            day = day <= 9 ? "0"+day : day;
            var year = currentTime.getFullYear();
            return year+"-"+month + "-"+day;                
        }
    },
    formoptions:{ rowpos:6,elmsuffix:"  yyyy-mm-dd", elmprefix:"&nbsp;&nbsp;&nbsp;&nbsp;"},
    editrules:{required:true}
}

这是我的代码..在网格日期字段中未显示,请帮助我.

This is my code ..in the grid date field is not displayed please help me.

推荐答案

问题是在页面上放置了某些版本的jqGrid调用dataInit 之前的el.因此,jQuery UI Datepicker在这种情况下不起作用.您可以通过调用datepicker 以后:

The problem is that some versions of jqGrid calls dataInit before the el are placed on the page. So jQuery UI Datepicker don't work in the case. You can fix the problem by calling datepicker later:

dataInit: function (el) {
    setTimeout(function () {
        $(el).datepicker({dateFormat:'yy-mm-dd '});
    }, 50);
}

这篇关于如何在jqgrid中添加datepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆