我在UI-GRid单元格中设置了jquery Datepicker,如下所示:
{ name: 'RDD', displayName: 'RDD', cellTemplate:'<input type="text" class="datepicker" id="{{row.entity.PartID}}" ng-model="row.entity.RDD" ng-value="row.entity.RDD" ng-click="grid.appScope.datepicker(row)" width="10px;" />',width:"*" },
and datepicker function as:-
$scope.datepicker = function(em)
{
alert('Do you want to change');
var RowID = '#' + em.entity.PartID;
//$(RowID).datepicker('show');
// alert(test);
$(RowID).datepicker(
{
minDate: 0,
dateFormat: 'mm-dd-yy',
onSelect: function(dateText, inst)
{
$(RowID).val("");
$scope.$(RowID).val(dateText) ;
//$('#36').val(dateText);
}
});
};
当我点击文本框时,datepicker打开,所选日期显示在文本框中。
但是当我点击提交按钮时,网格返回我的旧值(即数据库值)未被datepicker值选择
任何人都可以面对这个问题吗?帮助我吗?
答案 0 :(得分:0)
只需更改ng-model变量,并在希望它保存在DB中时获取指定的名称。
{ name: 'RDD', displayName: 'RDD', cellTemplate:'<input type="text" class="datepicker" id="{{row.entity.PartID}}" ng-model="selectedDate" ng-value="row.entity.RDD" ng-click="grid.appScope.datepicker(row)" width="10px;" />',width:"*" },
selectedDate 变量将始终更新日期。
答案 1 :(得分:0)
//I have changed
{ name: 'RDD', displayName: 'RDD', cellTemplate:'<input type="text" class="datepicker" id="{{row.entity.PartID}}" ng-model="row.entity.RDD" ng-value="row.entity.RDD" ng-click="grid.appScope.datepicker(row)" width="10px;" />',width:"*" },
//To
{ name: 'RDD', displayName: 'RDD', cellTemplate:'<input type="text" class="datepicker" ng-change="" id="{{row.entity.PartID}}" ng-model="row.entity.RDD" ng-value="row.entity.RDD" ng-click="grid.appScope.datepicker(row)" width="10px;" />',width:"*" },
//and added change event in datepicker function:-
$scope.datepicker = function(em)
{
alert('Do you want to change');
var RowID = '#' + em.entity.PartID;
$(RowID).datepicker(
{
minDate: 0,
dateFormat: 'mm-dd-yy',
onSelect: function(dateText, inst)
{
$(RowID).val("");
$(RowID).val(dateText).change() ;
}
});
};