在jQuery数据表中插入一个日期选择器

我有一个项目数据表,我想在一行中插入一个日期选择器。我有这个,但只显示输入没有日期选择器:在jQuery数据表中插入一个日期选择器

"render": function(data, type, full, meta){ 

var $tb = $("<input type='text' class='inlineevaldate' style='width:50px;'></input>");

$tb.attr("id", "etxt" + full[0]);

$("#etxt" + full[0]).val(full[12]);

return $tb.prop("outerHTML");

}

我可以用这个更新日期:

initComplete : function(settings, json){ 

$(".inlineevaldate").datepicker({

changeMonth: true,

changeYear: true,

modal: false,

autoClose: true,

onSelect: function() {

$("#btnUpdateProject").focus();

var whichrow = $(this);

var id = whichrow[0].id;

var val = whichrow[0].value;

var projectid = whichrow[0].id.substring(4);

$.ajax({

type: 'POST',

data: { projectid : projectid, date : val },

url: '@Url.Action("SetProjectEvalDate")',

success: function(data){

if (data === "ERROR") {

ErrorDialog("#MessageDialog", "#lblError", "The was an error encountered, please try again later.", "Error");

return false;

}

}

});

}

});

但我不能设置输入的初始值。有任何想法吗?

回答:

我渲染此列:

"render": function(data, type, full, meta){ 

var $tb = $("<input type='text' class='inlineevaldate' value='" + full[12] + "' style='width:50px;'></input>");

$tb.attr("id", "etxt" + full[0]);

return $tb.prop("outerHTML");

}

,然后配置日期选择器表后初始化:

initComplete : function(settings, json){ 

$(".inlineevaldate").datepicker({

changeMonth: true,

changeYear: true,

modal: false,

autoClose: true,

onSelect: function() {

$("#btnUpdateProject").focus();

var whichrow = $(this);

var id = whichrow[0].id;

var val = whichrow[0].value;

var projectid = whichrow[0].id.substring(4);

$.ajax({

type: 'POST',

data: { projectid : projectid, date : val },

url: '@Url.Action("SetProjectEvalDate")',

success: function(data){

if (data === "ERROR") {

ErrorDialog("#MessageDialog", "#lblError", "The was an error encountered, please try again later.", "Error");

return false;

}

}

});

}

});

以上是 在jQuery数据表中插入一个日期选择器 的全部内容, 来源链接: utcz.com/qa/263972.html

回到顶部