Hi Tejaswini,
Thanks for using Syncfusion products.
We have analyzed your reported issue for “TimePicker not displayed while editing the record” and we have created a sample. The sample can be downloaded from following link:
Sample: http://www.syncfusion.com/downloads/support/directtrac/118320/AngularJS1666165861.zip
Based on your code snippet we found that you are using editType as timePicker, which is the cause of issue. For your information, timePicker is not a default editType in grid editing. To use timePicker column in dialog edit mode, use actionComplete event to render the time picker. Please refer the following code snippet.
<body ng-controller="regularization_controller"> <div ej-grid id="Grid" e-width="500px" e-datasource="dataManager" e-allowpaging="true" e-editsettings-enablerowhover="true" e-editsettings-allowadding="true" e-editsettings-allowediting="true" e-editsettings-rowposition="bottom" e-editsettings-allowdeleting="true" e-editsettings-showconfirmdialog="false" e-toolbarsettings="toolbar" e-editsettings-editmode="dialog" e-actioncomplete="actionComplete"> <div e-columns> <div e-column e-field="OrderID" e-headertext="Order ID" e-width="60px" e-isprimarykey="true" e-textalign="left"></div> <div e-column e-field="OrderDate" e-width="150px" e-format="{0:hh:mm tt}" e-headertext="Order Time" e-textalign="center"></div> <div e-column e-field="Freight" e-width="120px" e-headertext="Freight" e-format="{0:c}" textalign="left"></div> <div e-column e-field="ShipName" e-width="120px" e-headertext="Ship Name" textalign="left"></div> <div e-column e-field="ShipCountry" e-headertext="Ship Country" e-width="100px" e-edittype="dropdownedit" e-textalign="center"></div> </div> </div> <script> angular.module('listCtrl', ['ejangular']) .controller('regularization_controller', function ($scope) { $scope.dataManager = window.gridData; $scope.toolbar = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] }; $scope.actionComplete = function actionComplete(args) { if (args.requestType == "beginedit" || args.requestType == "add") { $("#" + this._id + "OrderDate").ejTimePicker(); //GridId + Field name } } }); </script> |
Please try the above sample and get back to us if you have any queries.
Regards,
Sellappandi R
Hi Tejaswini,
Thanks for the update.
We have analyzed your requirement for “Need to store user entered details in localStorage” and created a sample. The sample can be downloaded from following link:
Sample: http://www.syncfusion.com/downloads/support/directtrac/118320/AngularJS.-922599284.zip
In the provided sample we have used actionComplete event to store the modified records in local storage. For your information, in local storage we must store the string value alone. So we are converting the modified records to string using stringify() method than we can convert this to object using parse(). Please refer the following code snippet.
<div ej-grid id="Grid" e-width="500px" e-datasource="dataManager" e-editsettings-showconfirmdialog="false" e-toolbarsettings="toolbar" e-editsettings-editmode="dialog" e-actioncomplete="actionComplete" > <div e-columns> <div e-column e-field="OrderID" e-headertext="Order ID" e-width="60px" e-isprimarykey="true" e-textalign="left"></div> …. </div> </div> <script> angular.module('listCtrl', ['ejangular']) .controller('regularization_controller', function ($scope) { $scope.dataManager = window.gridData; $scope.toolbar = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] }; $scope.actionComplete = function actionComplete(args) { if (args.requestType == "beginedit" || args.requestType == "add") { $("#" + this._id + "OrderDate").ejTimePicker(); } else if (args.requestType == "save") { window.localStorage.modifiedRecord = JSON.stringify(args.data); //Convert to string and Stored in localStorage var modifiedRecord = JSON.parse(window.localStorage.modifiedRecord || '{}'); //Convert to object from local storage } } }); |
Please try the above sample and get back to us if you have any queries.
Regards,
Hi Tejaswini,
Thanks for the update.
If we render the timePicker property, it will show the default value on editing time, so we need to set the current value to the timePicker property before editing.
Based on your requirement we have created a sample and the same can be downloaded from following link:
Sample: http://www.syncfusion.com/downloads/support/directtrac/118320/AngularJS_Sample-1073173167.zip
In the provided sample we have used actionComplete event to set the current grid value to time picker property. We have used getTime() method to get the time from UTC format. Please refer the following code snippet.
<script> angular.module('listCtrl', ['ejangular']) .controller('regularization_controller', function ($scope) { $scope.dataManager = window.scheduleData; $scope.toolbar = { showToolbar: true, toolbarItems: ["add", "edit", "delete", "update", "cancel"] }; $scope.actionComplete = function actionComplete(args) { if (args.requestType == "beginedit" || args.requestType == "add") { var time1 = getTime($("#" + this._id + "StartTime").val()); $("#" + this._id + "StartTime").ejTimePicker(); //GridId + Field name $("#" + this._id + "StartTime").ejTimePicker('model.value', time1);//Set the value to TimePicker var time2 = getTime($("#" + this._id + "EndTime").val()); $("#" + this._id + "EndTime").ejTimePicker(); //GridId + Field name $("#" + this._id + "EndTime").ejTimePicker('model.value', time2);//Set the value to TimePicker } else if (args.requestType == "save") { window.localStorage["modifiedRecord"] = JSON.stringify(args.data); //Convert to string and Stored in localStorage var modifiedRecord = JSON.parse(window.localStorage["modifiedRecord"] || '{}'); //Convert to object from local storage }
} }); function getTime(currentDate) { // Get the time alone from UTC var date = new Date(currentDate); ampm = 'AM', h = date.getHours(), m = date.getMinutes(); if (h >= 12) { if (h > 12) h -= 12; ampm = 'PM'; } if (m < 10) m = '0' + m; var time = h + ':' + m + ' ' + ampm; return time.toString(); } </script> |
Please try the above sample and get back to us if you have any queries.
Regards,
Sellappandi R
Hi Tejaswini,
Sorry about the inconvenience caused.
The reported issue is because of missing to add the condition getTime() method and after we save the record the element value set as time only, if we are not able to convert it in to date format. So it will return “NaN” and display the default value again if we edit the record. Please add the following condition in getTime() method to resolve the reported issue.
function getTime(currentDate) { // Get the time alone from UTC var date = new Date(currentDate); if ($(date.getDate()).length != 0) { ampm = 'AM', h = date.getHours(), m = date.getMinutes(); if (h >= 12) { if (h > 12) h -= 12; ampm = 'PM'; } if (m < 10) m = '0' + m; var time = h + ':' + m + ' ' + ampm; return time.toString(); } return currentDate; } |
We have also prepared a sample and it can be downloaded from following link:
Sample Link: http://www.syncfusion.com/downloads/support/forum/118497/JSAngularSample136090164.zip
Please let us know if you have any concerns.
Regards,
Sellappandi R
Hi Tejaswini,
Thanks for the update
Please find the response.
Query #1: How can showglyphicon for datepicker?
We have the default property showPopupButton in ejDatePicker. Please use this property to enable the date picker icon in dialog editor.
Refer the following code snippet to set the icon on datePicker.
if (args.requestType == "beginedit" || args.requestType == "add") { var time1 = getTime($("#" + this._id + "StartTime").val()); $("#" + this._id + "StartTime").ejTimePicker(); $("#" + this._id + "StartTime").ejTimePicker('model.value', time1); $("#" + this._id + "EndTime").ejDatePicker({showPopupButton:true}); } |
Query #2: How can i store the array of records to localstorage in angularjs and bind those records to grid?
We have created a sample based on your requirement and same can be downloaded from following link:
Sample: http://www.syncfusion.com/downloads/support/forum/118320/Sample_118320298492311.zip
In the above attached sample we have stored the data in local storage without overwrites in stored data. It will append the modified record in local storage. Please refer the following code snippet.
else if (args.requestType == "save") { var modifiedRecord = []; if (window.localStorage["modifiedRecord"] != undefined) modifiedRecord = JSON.parse(window.localStorage["modifiedRecord"] || '{}'); modifiedRecord.push(args.data); window.localStorage["modifiedRecord"] = JSON.stringify(modifiedRecord);//Stored modified records in string format } |
Please try the above sample and get back to us if you have any concerns.
Regards,