Hi Gomtesh,
Thanks for using Syncfusion Products.
We have analyzed your requirement and achieved by using the ej.Grid.prototype method in Grid. Please find the sample and code snippet.
<div id="Grid" ej-grid e-datasource="data" e-editsettings-allowadding="true">
<div e-columns> <div e-column e-field="OrderID" e-headertext="OrderID" e-isprimarykey="true" e-textalign="right" e-width="90"></div> <div e-column e-field="CustomerID" e-headertext="CustomerID" e-textalign="left" e-width="90"></div> <div e-column e-field="OrderDate" e-headertext="OrderDate" e-format="{0:dd-MM-yyyy}" e-edittype="datepicker" e-editparams-mindate="05-03-2015" e-width="90"></div> . . . . . . .
</div>
<script> ej.Grid.prototype._tags[0].attr.push("editParams.minDate");
angular.module('listCtrl', ['ejangular']) .controller('PhoneListCtrl', function ($scope) { $scope.selectedRow = 2; $scope.page = 2; $scope.data = window.gridData; $scope.tools = [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel]; }); </script> |
By using this method you can push the editparams properties in the Grid. Please find the sample for further details.
Sample: http://www.syncfusion.com/downloads/support/directtrac/118341/Angular-1335860692.zip
Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Hi Gomtesh,
Based on your requirement we have created the sample using angular. Please find the sample and code snippet.
Sample: Grid-angular.zip
<div id="Grid" ej-grid e-datasource="data" e-columns="col" e-toolbarsettings-showtoolbar='true' e-toolbarsettings-toolbaritems='toolbar' e-editsettings-allowdeleting=' true' e-editsettings-allowediting='true' e-editsettings-allowadding='true' e-allowpaging="true" e-editsettings-editmode='inlineformtemplate' e-editsettings-inlineformtemplateid="#template" e-selectedrowindex="selectedRow" e-allowsorting="true" e-actioncomplete="complete"> <div e-columns> <div e-column e-field="OrderID" e-headertext="OrderID" e-isprimarykey="true" e-textalign="right" e-width="90"></div> <div e-column e-field="CustomerID" e-headertext="CustomerID" e-textalign="left" e-width="90"></div> <div e-column e-field="FromDate" e-headertext="FromDate" e-format="{0:MM/dd/yyyy}" e-width="90"></div> <div e-column e-field="ToDate" e-headertext="ToDate" e-format="{0:MM/dd/yyyy}" e-width="90"></div> </div> </div>
|
By using the template form in Grid we have set the today date to the minDate for FromDate column and the value selected in the FromDate is set into minDate for the ToDate column. Please find the below code snippet.
<td style="text-align: right;"> From Date </td> <td style="text-align: left"> <input id="FromDate" ej-datepicker e-value="dateVal" e-mindate="mindate" e-select="change" /> </td> </tr> <tr> <td style="text-align: right;"> To Date </td> <td style="text-align: left"> <input id="ToDate" e-value="date" ej-datepicker e-mindate="dateVal" /> </td> |
Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Hi Gomtesh,
We have created the sample based on your requirement to calculating the number of days between from date and to date columns . Please find the sample and code snippet.
Sample: Angular.zip
<td style="text-align: right;"> EmployeeID </td> <td style="text-align: left"> <input id="EmployeeID" type="text" value="{{: EmployeeID}}" ej-numerictextbox e-change="noofdays()" e-value="leave_days" e-incrementstep="0.5" e-decimalplaces="1" e-minvalue="0.5"> </td> <tr> <td style="text-align: right;"> To Date </td> <td style="text-align: left"> <input id="ToDate" e-value="date" e-close="todate_close" ej-datepicker e-mindate="dateVal" /> </td> </tr>
<script> angular.module('listCtrl', ['ejangular']) .controller('PhoneListCtrl', function ($scope, $compile) { $scope.selectedRow = 2;
. . . . . . . . . . .
$scope.todate_close = function () { $scope.leave_days = (((new Date($scope.date).getTime()) - (new Date($scope.dateVal).getTime())) / (1000 * 60 * 60 * 24)) + 1; } } }); |
We suggest you to use the ej-numerictextbox directives in the input text box to update the calculating values to the textbox. Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Hi Gomtesh,
We are sorry for the inconvenience caused.
Please find the response.
If i select record for edit and if select from date and to date and press cancel button after that if you select another record for edit or add another record it give error in console |
We considered the requirement “Issue with editing while perform cancel” as a bug. We have logged a report on this and will fix the issue internally, also the fix will be included in Vol 1, 2015 service pack 1 release, which has been scheduled to be rolled out in the month of Apr 2015. | |
Also if i add new record the all textboxes and datepicker are not empty some values are present in that. |
In provided sample, you have changed the textbox and datepicker value as empty value while adding the new record. So its working properly as you expect in your provided sample | |
while editing if todate is greater than the current date then that record should not allowed for edit . |
We have achieved your requirement in the Grid “beginedit” event. Please find the sample and the code snippet. Sample: Angular-118341.zip
In this sample we have disabled the editing to the row, when the today is greater than the current date. | |
if i change no of days in textbox then "todate" should also change according to no of days according to from_date i.e if i put 3 in no_of_days textbox then date in "todate" should be 3 days from "from_date" |
We considered this requirement “Change event not triggered when changing the values in the numerictextbox” as bug and we have already fixed the issue internally. The fix will be included in our Vol 1, 2015, which has been scheduled to be rolled at the end of this month. |
Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Hi Gomtesh,
Sorry about the inconvenience caused.
We suggest you to use the name attribute in the jsrender template and the attribute name value should be same as the field of the column value.
Please find the sample and code snippet.
Sample: Sample-118341.zip
<body ng-controller="PhoneListCtrl"> <div class="content-container-fluid"> <div class="row"> <div class="cols-sample-area"> <div id="Grid" ej-grid e-datasource="data1"> <div e-columns> <div e-column e-field="leave_id" e-headertext="SrNo" e-isprimarykey="true" e-textalign="center"></div> <div e-column e-field="from_date" e-headertext="From Date" e-textalign="center" e-format="{0:dd-MMM-yyyy}"></div> <div e-column e-field="to_date" e-headertext="To Date" e-textalign="center" e-format="{0:dd-MMM-yyyy}"></div> <div e-column e-field="no_of_days" e-headertext="Leave days" e-textalign="center"></div> <div e-column e-field="reason" e-headertext="Reason" e-textalign="center"></div> <div e-column e-field="status" e-headertext="Status" e-edittype="dropdownedit" e-datasource="leave_status" e-textalign="center"></div> </div> </div> </div> </div> </div>
<script id="template" type="text/x-jsrender"> <table class="col-md-12" cellspacing="10"> . . . . . . .
<tr> <td style="text-align: right;"> No. of Days </td> <td style="text-align: left"> <input id="numeric" name="no_of_days" e-size="large" value="{{: no_of_days}}" class="col-lg-10 col-md-10 col-xs-10 col-sm-10 e-field ejinputtext syncfusion_textboxes_height" e-change="noofdays()" ng-change="noofdays()" e-value="leave_days" ng-model="leave_days" e-decimalplaces="1" valid-number>
</td> </tr>
<tr> <td style="text-align: right;"> Reason <td style="text-align: left">
<input id="reason" name="reason" value="{{: reason}}" class="e-field ej-textarea valid col-md-2 col-lg-6" row="2" e-value="reason" />
<!--<textarea id="reason" name="reason" value="{{: reason}}" e-value="reason1" class="e-field ej-textarea valid col-lg-12 col-md-12 col-xs-12 col-sm-12 " rows="2" />--> </td> </tr>
<tr> <td style="text-align: right;"> Status </td> <td style="text-align: left"> <input id="leave_status" name="status" value="{{: status}}" ej-dropdownlist e-datasource="leave_status" /> </td> </tr>
</table> </script>
angular.module('listCtrl', ['ejangular']) .controller('PhoneListCtrl', function ($scope, $compile) {
. . . . . . $scope.endedit = function (args) { if (args.data.status=="") args.data.status = $("#leave_status").val(); }
}); </script> |
Either you can specify the template id value should be same as the column field instead of the name attribute. Please find the below code snippet as follows.
<tr> <td style="text-align: right;"> No. of Days </td> <td style="text-align: left"> <input id="no_of_days" e-size="large" value="{{: no_of_days}}" class="col-lg-10 col-md-10 col-xs-10 col-sm-10 e-field ejinputtext syncfusion_textboxes_height" e-change="noofdays()" ng-change="noofdays()" e-value="leave_days" ng-model="leave_days" e-decimalplaces="1" valid-number>
</td> </tr>
<tr> <td style="text-align: right;"> Status </td> <td style="text-align: left"> <input id="status" value="{{: status}}" ej-dropdownlist e-datasource="leave_status" /> </td> </tr> |
Based on the attribute value only the records saved in the grid otherwise it will not be reflected in the grid view. Please let us know if you have any queries.
Regards,
Balaji Marimuhtu
I have to provide required field validation for all fields while add and editing records in grid in above your sent sample
In Sample-118341.zip i have make some changes and while adding new record i have set ID value as autoincreamented,if (args.requestType == "add") {//here i have set$scope.leave_id = (JSON.parse(localStorage.getItem('leaveList')).length) + 1;$scope.dateVal = null;$scope.date = null;$scope.leave_days = "";var scope = angular.element($("#Grid")).scope();scope.compile($(".gridform"));}all functionality works fine butas while editing record in grid ID will not allowed to edit in the same manner while adding record i have to not allow that auto incremented value from ID text boxi.e. i have disable that field
Hi Gomtesh,
Thanks for the update,
Query 1 : “provide required field validation for all fields”
Your requirement have been achieved by using e-validationrules-required property of columns in angular grid. Please find the below code snippet
<div id="Grid" ej-grid e-datasource="data1" e-toolbarsettings-showtoolbar='true' e-toolbarsettings-toolbaritems='tools' e-editsettings-allowdeleting=' true' e-editsettings-allowediting='true' e-editsettings-allowadding='true' e-allowpaging="true" e-beginedit="disableedit" e-editsettings-editmode='dialogtemplate' e-editsettings-inlineformtemplateid="#template" e-selectedrowindex="selectedRow" e-allowsorting="true" e-endedit="endedit" e-actioncomplete="complete"> <div e-columns> <div e-column e-field="leave_id" e-headertext="SrNo" e-isprimarykey="true" e-textalign="center" e-validationrules-required="true"></div> <div e-column e-field="from_date" e-headertext="From Date" e-textalign="center" e-format="{0:dd-MMM-yyyy}" e-validationrules-required="true"></div> <div e-column e-field="to_date" e-headertext="To Date" e-textalign="center" e-format="{0:dd-MMM-yyyy}" e-validationrules-required="true"></div> <div e-column e-field="no_of_days" e-headertext="Leave days" e-textalign="center" e-validationrules-required="true"></div> <div e-column e-field="reason" e-headertext="Reason" e-textalign="center" e-validationrules-required="true"></div> <div e-column e-field="status" e-headertext="Status" e-edittype="dropdownedit" e-datasource="leave_status" e-textalign="center" e-validationrules-required="true"></div> </div> </div> |
For your convenience we have created a sample and sample can be downloaded from the below link
Query 2 : “ Have to disable the field while adding record with auto – incremented value”
Your requirement have been achieved by the use {{if}} and {{else}} jsrender template tag. While adding new record we set ID value as autoincremented by using ng –model directive and jquery addClass we disable the ID value.
Please find the below code snippet :
<td style="text-align: left"> {{if leave_id}} <input id="leave_id" name="" value="{{:leave_id}}" disabled="disabled" class="e-field e-ejinputtext valid e-disable col-lg-10 col-md-10 col-xs-10 col-sm-10 syncfusion_textboxes_height" /> {{else}} <input id="leave_id" name="" ng-model="leave" disabled="disabled" class="e-field e-ejinputtext valid e-disable col-lg-10 col-md-10 col-xs-10 col-sm-10 syncfusion_textboxes_height" /> {{/if}} </td> ------------------------------------------------------------------------------------ if (args.requestType == "add") { $scope.leave = ($scope.data1).length + 1; $($(args.target).find(".e-addedrow").find('input')[0]).addClass("e-disable"); $scope.dateVal = null; $scope.date = null; $scope.leave_days = ""; var scope = angular.element($("#Grid")).scope(); scope.compile($(".gridform")); } |
For your convenience we have created a sample and sample can be downloaded from the below link
Sample Link : http://www.syncfusion.com/downloads/support/forum/118341/Sample-118341-1128883569.zip
Query 3 : “it not fetching the record value while editing record”
While using textarea field we suggest to define the value in the inner html. Then only the data can be binded while editing or adding record. Please find the below code snippet
<textarea id="reason" name="reason" class="e-field ej-textarea valid col-lg-12 col-md-12 col-xs-12 col-sm-12 " rows="2" >{{: reason}}</textarea> |
For your convenience we have created a sample and sample can be downloaded from the above link
If we misunderstand your query please get back to us, we will happy to assist you,
Regards,
Prasanna Kumar N.S.V
Hi Gomtesh,
We are sorry about the inconvenience caused.
Query: works with only from_date and to_date but not with reason,no_of_days and statusfield while add and editing record in grid.
We have modified the sample and please find the sample and code snippet.
Sample: Sample-118341.zip
We suggest you to use the field name as id attribute for the input template. Because validation is worked based on id attribute only. And please refer the sample for further details.
<tr> <td style="text-align: right;"> No. of Days </td> <td style="text-align: left"> <input id="no_of_days" name="no_of_days" e-size="large" value="{{: no_of_days}}" class="col-lg-10 col-md-10 col-xs-10 col-sm-10 e-field ejinputtext syncfusion_textboxes_height" e-change="noofdays()" ng-change="noofdays()" e-value="leave_days" ng-model="leave_days" e-decimalplaces="1" valid-number> </td> </tr> |
Query: it show disabled field then also it is editable field
Your requirement is achieved by using the actionComplete event in Grid and set the disabled attribute to the “leave_id” column for disabled the column value and also as non-editable.
$scope.complete = function (args) { if (args.requestType == "save") debugger if (args.requestType == "add") { $scope.leave = ($scope.data1).length + 1; $($(args.target).find(".e-addedrow").find('input')[0]).addClass("e-disable").attr("disabled","disabled"); $scope.dateVal = null; $scope.date = null; $scope.leave_days = ""; var scope = angular.element($("#Grid")).scope(); scope.compile($(".gridform")); } |
Please let us know if you have any queries.
Regards,
Balaji Marimuthu