微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

asp.net-mvc – jqGrid中的日期选择器,简单的例子?

有没有人知道在jqgrid添加 jquery UI DatePicker(或其他一些)的例子?我正试图让它适用于内联编辑网格.

我找到了一些例子,但没有任何作用.我想要一些非常简单的东西!

我的网格设置(不知道这个问题是否属于nessecary):

$(function () {
    var lastsel;
    $("#list").jqgrid({
        url: '@Url.Action("ExampleData","Home")',datatype: 'json',mtype: 'GET',colNames: ['Namn','Födelsedag','Adress','Stad'],colModel: [
          { name: 'Name',index: 'Name',width: 130,editable: true },{ name: 'Birthday',index: 'Birthday',width: 80,// DatePicker for birthday 

          { name: 'Address',index: 'Address',width: 180,{ name: 'City',index: 'City',],pager: '#pager',rowNum: 10,rowList: [10,20,30],sortname: 'Name',sortorder: 'desc',viewrecords: true,gridview: true,width: 700,onSelectRow: function (id) {
            if (id && id !== lastsel) {
                jQuery('#list').jqgrid('saveRow',lastsel);
                jQuery('#list').jqgrid('editRow',id,true);
                lastsel = id;
            }
        },editurl: '@Url.Action("Incoming",caption: 'Kontaktpersoner'
    });

    jQuery("#list").jqgrid('navGrid',"#pager",{ edit: false,add: false,del: true });
    jQuery("#list").jqgrid('inlineNav',"#pager");

解决方法

正如您在 jqGrid documentation中可以看到的那样,有一个dataInit选项.您应该记住,在将元素插入DOM之前引发此事件,因此使用setTimeout只是为了安全:

{ name: 'Birthday',editable: true editoptions: { dataInit: function(el) { setTimeout(function() { $(el).datepicker(); },200); } } },

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐