Skip to main content

Posts

Showing posts with the label Javascript

D365 grid selected row id into javascript

 If you want to get all selected values of a subgrid you can try with this sample. var gridContext = formContext.getControl("AttendeesSubgrid"); var allSelectedRows = gridContext.getGrid().getSelectedRows(); var attendeeList = []; allSelectedRows.forEach(GetSelectedRecord); function GetSelectedRecord(item) { var rowData = item._entityId; var attendiee = rowData.guid; attendeeList.push(attendiee); }

D365 java script on load event change code

 This is very common that some times we need to set value into another field based on change event or into form load event. Normally we define the code into load event and into change event. We can replace the load event using fireOnChange(); if (formContext.getAttribute("studentid")) { formContext.getAttribute("studentid").fireOnChange(); } If this field value has change event then you do not need to define into load event. fireOnChange() event will work for load event.

Dynamics 365 Set a Lookup Field Using JavaScript from another lookup selection change

 In my case, I will select a contact from lookup and it will fill the account lookup field. function OnContactChange(executionContext) { var formContext = executionContext.getFormContext(); if (formContext.getAttribute("parentcontactid").getValue() != null) { var CustomerId = formContext.getAttribute("parentcontactid").getValue()[0].id.slice(1, -1); var CustomerName = formContext.getAttribute("parentcontactid").getValue()[0].name; var CustomerType = formContext.getAttribute("parentcontactid").getValue()[0].entityType; // Call contact API Xrm.WebApi.retrieveRecord("contact", CustomerId, "?$select=_parentcustomerid_value").then( function success(contactresult) { // Call Account Xrm.WebApi.retrieveRecord("account", contactresult._parentcustomerid_val...

ASP.NET Get radio button value in javascript

Radio button html <input type="radio" name="mxCard" id="mxcard" data-id="<%=mxcard.MxFormaterCreditCard%>" value="<%=mxcard.MxFormaterCreditCard%>" /> get radio button value in java script var selectedVal = ""; var selected = $('input[type=radio][name=mxCard]:checked').val(); if (selected) { // Do something } }

ajax call using jquery in asp.net

Event: <a class="btnTwo btnTwoOrange btnSelectSend" href="JavaScript:" id="btnSelectSend" onclick="SendEmail();">Gönder</a> Javascript: <script type="text/javascript"> function SendEmail() { var bookId = document.getElementById("BookID").value; var name = document.getElementById("sendername").value; var email = document.getElementById("senderEmail").value; $.ajax({ type: "POST", url: "Forbes.aspx/SendEmail", data: "{ bookId: '" + bookId + "',name: '" + name + "',email: '" + email + "'}", contentType: "application/json; charset=utf-8", dataType: "json", async: "true", cache: "false", success: function (...

Javascript Yes / No confirm dialog

You can see this function Remove(ctrl) { if (confirm('Pressing OK will delete this record. Do you want to continue?') == false) { return false; } var row = $(ctrl).parent().parent().parent().children().index($(ctrl).parent().parent()); // alert(row); $("#refRowIndex").val(row); var form = $("#frmStudentDetails"); var serializedForm = form.serialize(); var url = "/Student/RemoveStudentDetails"; $.post(url, serializedForm, function (result) { $("#divStudentDetails").html(result); }, "html"); return false; }

asp.net mvc checkbox will check all the check box in html table

Table: <table class="rptcontenttext" style="width: 100%; border-style: solid; border-collapse: collapse" border="1px" cellpadding="0" cellspacing="0"> <thead> <tr> <th style="text-align:left;width:10px;"> <input type="checkbox" value="true" name="chkVerifySelection" id="chkVerifySelection" onchange="return checkAllVerifySelection();" /> </th> <td class="rptrowdata" align="left"> Employee ID </td> </tr> </thead> <tbody style="overflow-y: auto; overflow-x: hidden; max-height: 400px; width: 100%;"> @for (int i = 0; i < Model.EmployeeInformationList.Count; i++) { <...

kendo grid checkbox check validation

In the following above image i want to transfer from left side grid data to right side grid & only the selected grid item. I will check that - The left grid can check more than one checkbox - right side grid will check only one. - left & right side selection item will not same. Then all the selected check box in the left side will get for right side person for save or update as you want. Transfer button click: <button type="submit" class="btn btn-mini btn-primary" onclick="AccountsManagerTransferResponsiblity()"> <i class="icon-retweet"></i>Transfer </button> Script: function AccountsManagerTransferResponsiblity() { var gridData1 = $("#CustomerAccountManagerKendoGrid1").data("kendoGrid").dataSource.data(); var gridData2 = $("#CustomerAccountManagerKendoGrid2").data("kendoGrid").dataSource.data(); if (!CheckGr...

on demand parameter in kendo grid load

On demand event // Bouquet combo change event $('#BooketID').live('change', function () { FillChannelGridByBouquetID(); }); set parameter for grid load /* Load kendo grid by bouquetID*/ function FillChannelGridByBouquetID() { var a = {}; a.BooketID = $("#BooketID option:selected").val(); var mAGrid = $('#CustomerPackageChannelKendoGrid').data('kendoGrid'); mAGrid.dataSource.read(a); } Grid $("#CustomerPackageChannelKendoGrid").kendoGrid({ dataSource: { transport: { read: "ChannelReadByBooketID", }, schema: { model: { fields: { SelectColumn: {type: "boolean"}, ChannelID: { type: "string" }, BooketName: { type: "string" }, ChannelName: { type: ...

format kendo grid date column field

I share the script of the grid, Hope it will help you. //start Kendo UI Grid $("#CustomerAccountManageKendoGrid").kendoGrid({ dataSource: { transport: { read: "CustomerAccountManageRead" }, schema: { model: { fields: { CustomerAccountManageID: { type: "string" }, ManagerName: { type: "string" }, CustomerName: { type: "string" }, AssignDate: { type: "date" }, ActiveStatus: { type: "string" }, ActionLink: { type: "string" } } } }, pageSize: 20, serverPaging: false, serverFiltering: false, serverSorting: false }, height: 600, filterable: true, groupable: true, sortable: true, resizable: true, pageable: { refresh: true, ...

Post Kendo Grid data with model data to Controller in MVC

Your save button: <button type="submit" class="btn btn-mini btn-primary" id="btnAddCustomerAccountManage" name="btnAddCustomerAccountManage" onclick="SaveUserProjectDetails()"> <i class="icon-save bigger-125"></i>Save</button> button click function function SaveUserProjectDetails () { var projectPermissionType = 1; var postUrl; var paramValue; if (projectPermissionType == 1) { var gridData = $("#CustomerInfoKendoGrid").data("kendoGrid").dataSource.data(); // set model data for (var i = 0; i < gridData.length; i++) { gridData[i].ManagerGenInfoID = $("#GEmployeeGenInfoID").val(); gridData[i].AssignDate = $("#AssignDate").val(); } postUrl = '@Url.Content("~/Billing/CustomerAccountManage/GetDepartmentWiseCategoryList")'; ...

html get checkbox value by id

try this: <input id="SelectedCB" type="checkbox" style = "z-index: 99999 !important; margin-top: 0px;" onchange="return getCustomer(this);" /> function getCustomer(ctrl) { if ($('#SelectedCB').is(':checked')) { alert('checked'); } else { alert('Unchecked'); } return false; }

asp.net mvc add & remove item from html table

To add & remove item in HTML table like this image you can like the this: Model: public class StudentDetailsModels { public System.Guid? StudentId { get; set; } public System.String StudentName { get; set; } public System.String StudentFatherName { get; set; } public System.String StudentAddress { get; set; } } public class StudentModels { [Key] public System.Guid? StudentId { get; set; } public System.String StudentName { get; set; } public System.String StudentFatherName { get; set; } public System.String StudentAddress { get; set; } private List<StudentDetailsModels> _studentDetailsList = new List<StudentDetailsModels>(); public List<StudentDetailsModels> StudentDetailsList { get { return _studentDetailsList; } set { _studentDetailsList = value; } } } View: @{ ViewBag.Title = "StudentInfo"; ...

MVC CheckBoxFor value set from script

If we want to set value in CheckBoxFor value from script we can set value like this: function EditAccessPrevilige(AccessPrivilegeID, LoginID, EmployeeAccessPrivilege, PayrollPrivilege) { $('#AccessPrivilegeInfo_LoginID').val(LoginID); if (EmployeeAccessPrivilege == "True") document.getElementById("AccessPrivilegeInfo_EmployeeAccessPrivilege").checked = true; else document.getElementById("AccessPrivilegeInfo_EmployeeAccessPrivilege").checked = false; if (PayrollPrivilege == "True") document.getElementById("AccessPrivilegeInfo_PayrollPrivilege").checked = true; else document.getElementById("AccessPrivilegeInfo_PayrollPrivilege").checked = false; return false; }

mvc razor textboxfor change event change another textboxfor value

Based on value of Weight, Rate , CNF & AWB it will change the value of Freight , TTLCNF anfd TTLFright . Freight= Weight*Rate; TTLCNF  = Weight*CNF; TTLFright=  Freight+ TTLCNF  + AWB; @Html.TextBoxFor(model => model.Weight, new { onChange="return GetWight(this);"}) @Html.TextBoxFor(model => model.Rate, new { onChange="return GetWight(this);"})/Kg @Html.TextBoxFor(model => model.Freight, new {disabled = "disabled" , @readonly = "readonly" ,onChange="return GetTTLFright(this);"}) @Html.TextBoxFor(model => model.CNFPK, new { onChange="return GetCNFPK(this);"}) @Html.TextBoxFor(model => model.TTLCNF, new {disabled = "disabled" , @readonly = "readonly",onChange="return GetTTLFright(this);" }) @Html.TextBoxFor(model => model.AWB, new { onChange="return GetTTLFright(this);"}) and script <script> function GetW...

MVC razor table row date to compare date between other 2 date in javascript

Consider the senerio of the image that i want to select date from table row date and my selected date will check other 2 date between in javascript. First i am getting the event of date change: </td> <td class="rptrowdata" align="center" style="width: 65px"> @{ if (Model.EmployeeInformationList[i].OutGoingDate == DateTime.MinValue || Model.EmployeeInformationList[i].OutGoingDate == null) { @Html.TextBoxFor(m => m.EmployeeInformationList[i].strOutGoingDate, new { @class = "textRegular dtPicker pmtallocated pull-right", @readOnly = "readOnly", maxlength = "10",@dir = "rtl",@onchange = "return DateChecker(this);" }) } else { <input type="hidden" value="@Model.EmployeeInformationList[i].Out...

mvc razor selected datepicker will add 3 month in another datepicker

  Before select date  after select date if you want to select any date from a date picker and it will add 3 month / as your self  in another date picker, you can easily do it using script on change event of you first date picker. @Html.TextBoxFor(m => m.MaternityLeave.strSymptomDate, new { @class = "textRegular requiredSub dtPicker", @readOnly = "readOnly", maxlength = "10", onchange = "return getConfirmationDate();" }) second date picker @Html.TextBoxFor(m => m.MaternityLeave.strApplyDate, new { @class = "textRegular requiredSub dtPicker", @readOnly = "readOnly", maxlength = "10" }) on change event script function getConfirmationDate() { var confirmOld = $("#MaternityLeave_strSymptomDate").val(); var mySplitResult = confirmOld.split("-"); var confirm_date = mySplitResult[0].toString(); var confirm_month = parseFloat(mySplitResult[1].t...