加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-16 03:39:08 所属栏目:asp.Net 来源:网络整理
导读:有没有人知道在jqGrid中添加 jquery UI DatePicker(或其他一些)的例子?我正试图让它适用于内联编辑网格. 我找到了一些例子,但没有任何作用.我想要一些非常简单的东西! 我的网格设置(不知道这个问题是否属于nessecary): $(function () { var lastsel; $("#
有没有人知道在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); } } },

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读