Bhushan Bhushan - 27 days ago 9
AngularJS Question

I am not getting Jquery datepicker value on submit button from UIGRid

I have set jquery Datepicker in UI-GRid cell as below:

{ 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);
}
});
};


When I click on textbox datepicker is open and selected date is displayed in textbox .

But when I click on submit button the grid is return me old value(i.e database value) not selected by datepicker value

Can any one face this issue & help me in it?

Answer
//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() ;


         }
      });


   };