jQuery UI Widgets Forums Grid Grid rowdetail and Insert

This topic contains 6 replies, has 2 voices, and was last updated by  jperera 9 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • Grid rowdetail and Insert #68414

    jperera
    Participant

    Good morning…
    First I want to thank you all for your help, it’s very important for people like me starting now with the widgets!!

    I have a functionality with a jqxGrid with rowsdetails, in each rowsdetails I’m inserting, deleting, and editing some information… The problem that I have it’s the following:
    When I insert for first time everything is ok, when I close the detail and open the detail of other row and I want to insert then the insert work ok but its repeat twice, the in same way everytime that I open a new rowdetail the event addrow is fire the same times…

    I know my issues could be unexpecting but please help me with that!!
    Thank you

    Grid rowdetail and Insert #68420

    Dimitar
    Participant

    Hello jperera,

    It is possible that you bind to an event (i.e. rowexpand) multiple times, which results in the reported behaviour. Please share the relevant parts of your code so that we may determine what is wrong.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Grid rowdetail and Insert #68426

    jperera
    Participant

    Thanks Dimitar, this is a relevant part for the code:

    function LoadContacts() {
    			$.ajax({
    				type: "POST",
    				url: '@Url.Action("LoadContacts", "Contact")',
    				data: {},
    				contentType: "application/json; charset=utf-8",
    				dataType: "json",
    				success: function (data) {
    					for (var i = 0; i < data.length; i++) {
    						if (data[i].ExpireDate != null)
    							data[i].ExpireDate = data[i].ExpireDate.replace(/\d+/,
    								function (n) {
    									var time = parseInt(n);
    									return parseInt(time) + new Date(time).getTimezoneOffset() * 60000
    								}
    							);
    					}
    					var sourceContact =
    						{
    							datatype: "json",
    							datafields: [
    								{ name: 'AddWebUserFlag', type: 'bool' },
    								{ name: 'Authority', type: 'string' },
    								{ name: 'AuthorityDescription', type: 'string' },
    								{ name: 'ContactNum', type: 'int' },
    								{ name: 'DisplayExpiredFlag', type: 'bool' },
    								{ name: 'DocumentNum', type: 'int' },
    								{ name: 'DocumentSeqNum', type: 'int' },
    								{ name: 'ECVFlag', type: 'bool' },
    								{ name: 'ExpireDate', type: 'date', format: "M/d/yyyy" },
    								{ name: 'ExpiredFlag', type: 'bool' },
    								{ name: 'FirstName', type: 'string' },
    								{ name: 'HighlightContactNum', type: 'int' },
    								{ name: 'HighlightFlag', type: 'bool' },
    								{ name: 'KeyNum', type: 'int' },
    								{ name: 'KeysFlag', type: 'bool' },
    								{ name: 'KeyType', type: 'string' },
    								{ name: 'LastName', type: 'string' },
    								{ name: 'MiddleName', type: 'string' },
    								{ name: 'Name', type: 'string' },
    								{ name: 'PatientFlag', type: 'bool' },
    								{ name: 'PhoneList', type: 'string' },
    								{ name: 'PIN', type: 'string' },
    								{ name: 'Relation', type: 'string' },
    								{ name: 'RelationDescription', type: 'string' },
    								{ name: 'SearchName', type: 'string' },
    								{ name: 'SearchPIN', type: 'string' },
    								{ name: 'SeqNum', type: 'int' },
    								{ name: 'SiteName', type: 'string' },
    								{ name: 'StartOrderNum', type: 'int' },
    								{ name: 'Suffix', type: 'string' },
    								{ name: 'Title', type: 'string' },
    								{ name: 'UserID', type: 'string' },
    								{ name: 'XtApplicationName', type: 'string' },
    								{ name: 'BadNumberFlag', type: 'bool' },
    								{ name: 'ContactInfoHtml', type: 'string' }
    							],
    							localdata: data,
    							addrow: function (rowid, rowdata, position, commit) {
    
    								var params = "{" + "'FirstName':'" + rowdata.FirstName + "'," + "'MiddleInicial':'" + rowdata.MiddleName + "'," + "'LastName':'" + rowdata.LastName + "'," + "'Title':'" + rowdata.Title + "'," + "'Suffix':'" + rowdata.Suffix + "'," + "'ECV':'" + rowdata.ECVFlag + "'," + "'Keys':'" + rowdata.KeysFlag + "'," + "'Authority':'" + rowdata.Authority + "'," + "'Relation':'" + rowdata.Relation + "'," + "'Passcode':'" + rowdata.PIN + "'," + "'BeginDate':'" + rowdata.EffectiveDate + "'," + "'ExpireDate':'" + rowdata.ExpireDate + "'}";
    								$.ajax({
    									type: "POST",
    									url: '@Url.Action("CreateContact", "Contact")',
    									data: params,
    									contentType: "application/json; charset=utf-8",
    									dataType: "json",
    									success: function (dataA) {
    										if (dataA.Success == true) {
    											rowdata.Authority = dataA.Obj.Authority;
    											rowdata.AuthorityDescription = dataA.Obj.AuthorityDescription;
    											rowdata.ContactNum = dataA.Obj.ContactNum;
    											rowdata.DocumentNum = dataA.Obj.DocumentNum;
    											rowdata.ECVFlag = dataA.Obj.ECVFlag;
    											rowdata.ExpiredFlag = dataA.Obj.ExpiredFlag;
    											rowdata.FirstName = dataA.Obj.FirstName;
    											rowdata.KeyNum = dataA.Obj.KeyNum;
    											rowdata.KeysFlag = dataA.Obj.KeysFlag;
    											rowdata.KeyType = dataA.Obj.KeyType;
    											rowdata.LastName = dataA.Obj.LastName;
    											rowdata.MiddleName = dataA.Obj.MiddleName;
    											rowdata.Name = dataA.Obj.Name;
    											rowdata.PatientFlag = dataA.Obj.PatientFlag;
    											rowdata.PIN = dataA.Obj.PIN;
    											rowdata.Relation = dataA.Obj.Relation;
    											rowdata.RelationDescription = dataA.Obj.RelationDescription;
    											rowdata.SeqNum = dataA.Obj.SeqNum;
    											rowdata.SiteName = dataA.Obj.SiteName;
    											rowdata.Suffix = dataA.Obj.Suffix;
    											rowdata.Title = dataA.Obj.Title;
    											rowdata.UserID = dataA.Obj.UserID;
    											rowdata.BadNumberFlag = dataA.Obj.BadNumberFlag;
    											rowdata.ContactInfoHtml = dataA.Obj.ContactInfoHtml;
    											$("#lbNotificationSuccess").text("Contact Created Successfully");
    											$("#jqxNotificationSuccess").jqxNotification("open");
    											commit(true);
    										}
    										else {
    											$("#lbNotification").text("An error occured. " + data.Message);
    											$("#jqxNotification").jqxNotification("open");
    											commit(false);
    										}
    									}
    								});
    							},
    							updaterow: function (rowid, rowdata, commit) {
    								var rowOldData = $('#gvContacts').jqxGrid('getrowdata', rowid);
    								var params = "{" + "'ContactNum':" + rowOldData.ContactNum + "," + "'KeyNum':" + rowOldData.KeyNum + "," + "'KeyType':'" + rowOldData.KeyType + "'," + "'orderNumber':" + rowOldData.SeqNum + "," + "'FirstName':'" + rowdata.FirstName + "'," + "'MiddleInicial':'" + rowdata.MiddleName + "'," + "'LastName':'" + rowdata.LastName + "'," + "'Title':'" + rowdata.Title + "'," + "'Suffix':'" + rowdata.Suffix + "'," + "'ECV':'" + rowdata.ECVFlag + "'," + "'Keys':'" + rowdata.KeysFlag + "'," + "'Authority':'" + rowdata.Authority + "'," + "'Relation':'" + rowdata.Relation + "'," + "'Passcode':'" + rowdata.PIN + "'," + "'BeginDate':'" + rowdata.EffectiveDate + "'," + "'ExpireDate':'" + rowdata.ExpireDate + "'}";
    								$.ajax({
    									type: "POST",
    									url: '@Url.Action("UpdateContact", "Contact")',
    									data: params,
    									contentType: "application/json; charset=utf-8",
    									dataType: "json",
    									success: function (dataA) {
    										if (dataA.Success == true) {
    											rowdata.Authority = dataA.Obj.Authority;
    											rowdata.AuthorityDescription = dataA.Obj.AuthorityDescription;
    											rowdata.ContactNum = dataA.Obj.ContactNum;
    											rowdata.DocumentNum = dataA.Obj.DocumentNum;
    											rowdata.ECVFlag = dataA.Obj.ECVFlag;
    											rowdata.ExpiredFlag = dataA.Obj.ExpiredFlag;
    											rowdata.FirstName = dataA.Obj.FirstName;
    											rowdata.KeyNum = dataA.Obj.KeyNum;
    											rowdata.KeysFlag = dataA.Obj.KeysFlag;
    											rowdata.KeyType = dataA.Obj.KeyType;
    											rowdata.LastName = dataA.Obj.LastName;
    											rowdata.MiddleName = dataA.Obj.MiddleName;
    											rowdata.Name = dataA.Obj.Name;
    											rowdata.PatientFlag = dataA.Obj.PatientFlag;
    											rowdata.PIN = dataA.Obj.PIN;
    											rowdata.Relation = dataA.Obj.Relation;
    											rowdata.RelationDescription = dataA.Obj.RelationDescription;
    											rowdata.SeqNum = dataA.Obj.SeqNum;
    											rowdata.SiteName = dataA.Obj.SiteName;
    											rowdata.Suffix = dataA.Obj.Suffix;
    											rowdata.Title = dataA.Obj.Title;
    											rowdata.UserID = dataA.Obj.UserID;
    											rowdata.BadNumberFlag = dataA.Obj.BadNumberFlag;
    											rowdata.ContactInfoHtml = dataA.Obj.ContactInfoHtml;
    											rowdata.PhoneList = dataA.Obj.PhoneList;
    											$("#lbNotificationSuccess").text("Contact Updated Successfully");
    											$("#jqxNotificationSuccess").jqxNotification("open");
    											commit(true);
    										}
    										else {
    											$("#lbNotification").text("An error occured. " + data.Message);
    											$("#jqxNotification").jqxNotification("open");
    											commit(false);
    										}
    									}
    								});
    
    							},
    							deleterow: function (rowid, commit) {
    								var rowOldData = $('#gvContacts').jqxGrid('getrowdata', rowid);
    								var params = "{" + "'ContactNum':" + rowOldData.ContactNum + "," + "'KeyNum':" + rowOldData.KeyNum + "," + "'KeyType':'" + rowOldData.KeyType + "'}";
    								$.ajax({
    									type: "POST",
    									url: '@Url.Action("DeleteContact", "Contact")',
    									data: params,
    									contentType: "application/json; charset=utf-8",
    									dataType: "json",
    									success: function (data) {
    										if (data.Success == true) {
    											$("#lbNotificationSuccess").text("Contact Remove Successfully");
    											$("#jqxNotificationSuccess").jqxNotification("open");
    											commit(true);
    										}
    										else {
    											$("#lbNotification").text("An error occured. " + data.Message);
    											$("#jqxNotification").jqxNotification("open");
    											commit(false);
    										}
    									}
    								});
    							}
    						}
    					var dataAdapterContacts = new $.jqx.dataAdapter(sourceContact);
    					var editrow = -1;
    					var cellclass = function (row, columnfield, value, data) {
    						if (data.BadNumberFlag == true && columnfield != 'BadNumberFlag' && data.ExpiredFlag == false) {
    							return 'badphonegrid';
    						}
    						if (data.ExpiredFlag == true && columnfield != 'ExpiredFlag') {
    							return 'expphonegrid';
    						}
    					}
    					var firstNameColumnFilter = function () {
    						var filtergroup = new $.jqx.filter();
    						var filtervalue = false;
    						var filtercondition = 'equal';
    						var filter = filtergroup.createfilter('booleanfilter', filtervalue, filtercondition);
    						filtergroup.addfilter(1, filter);
    						return filtergroup;
    					}();
    					var tooltiprenderer = function (element) {
    						$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    					}
    					var initrowdetails = function (index, parentElement, gridElement, datarecord) {
    						var tabsdiv = null;
    						var ContactDetailInfo = null;
    						var ContactPhonesInfo = null;
    						var ContactEmailInfo = null;
    						var ContactListMemberInfo = null;
    						var ContactPasscodesInfo = null;
    						var ContactUserIdsInfo = null;
    						var ContactTempDeactivateInfo = null;
    						var ContactScheduleInfo = null;
    						var ContactMedicalDataInfo = null;
    						tabsdiv = $($(parentElement).children()[0]);
    						if (tabsdiv != null) {
    							//Detail
    							ContactDetailInfo = tabsdiv.find('.ContactDetailInfo');
    							var title = tabsdiv.find('.ContactDetail');
    							title.text("Details");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactDetailInfo));
    							var leftcolumn = $('<div style="float: left; width: 45%;"></div>');
    							var rightcolumn = $('<div style="float: left; width: 40%;"></div>');
    							container.append(leftcolumn);
    							container.append(rightcolumn);
    							var paramsDetail = "{" + "'ContactNum':" + datarecord.ContactNum + "," + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'}";
    							$.ajax({
    								type: "POST",
    								url: '@Url.Action("GetDetailByContact", "Contact")',
    								data: paramsDetail,
    								contentType: "application/json; charset=utf-8",
    								dataType: "json",
    								cache: false,
    								success: function (data) {
    									for (var i = 0; i < data.length; i++) {
    										if (data[i].EffectiveDate != null)
    											data[i].EffectiveDate = data[i].EffectiveDate.replace(/\d+/,
    												function (n) {
    													var time = parseInt(n);
    													return parseInt(time) + new Date(time).getTimezoneOffset() * 60000
    												}
    											);
    										if (data[i].ExpireDate != null)
    											data[i].ExpireDate = data[i].ExpireDate.replace(/\d+/,
    												function (n) {
    													var time = parseInt(n);
    													return parseInt(time) + new Date(time).getTimezoneOffset() * 60000
    												}
    											);
    									}
    									var sourceContactDetail =
    											{
    												datatype: "json",
    												datafields: [
    													{ name: 'SeqNum', type: 'int' },
    													{ name: 'FirstName', type: 'string' },
    													{ name: 'MiddleName', type: 'string' },
    													{ name: 'LastName', type: 'string' },
    													{ name: 'Title', type: 'string' },
    													{ name: 'Suffix', type: 'string' },
    													{ name: 'ECVFlag', type: 'bool' },
    													{ name: 'KeysFlag', type: 'bool' },
    													{ name: 'AuthorityDescription', type: 'string' },
    													{ name: 'RelationDescription', type: 'string' },
    													{ name: 'ContactInfoHtml', type: 'string' },
    													{ name: 'PIN', type: 'string' },
    													{ name: 'EffectiveDate', type: 'date', format: "M/d/yyyy" },
    													{ name: 'ExpireDate', type: 'date', format: "M/d/yyyy" }
    												],
    												localdata: data,
    											}
    									var dataAdapterCDetail = new $.jqx.dataAdapter(sourceContactDetail);
    									dataAdapterCDetail.dataBind();
    									var orderhtml = "<div style='margin: 10px;'><b>Order#:</b> " + dataAdapterCDetail.records[0].SeqNum + "</div>";
    									var FirstNamehtml = "<div style='margin: 10px;'><b>First Name:</b> " + dataAdapterCDetail.records[0].FirstName + "</div>";
    									var middlename = "";
    									if (dataAdapterCDetail.records[0].MiddleName != null)
    										middlename = dataAdapterCDetail.records[0].MiddleName;
    									var MiddleInitialhtml = "<div style='margin: 10px;'><b>Middle Initial:</b> " + middlename + "</div>";
    									var LastNamehtml = "<div style='margin: 10px;'><b>Last Name:</b> " + dataAdapterCDetail.records[0].LastName + "</div>";
    									var tittle = ""
    									if (dataAdapterCDetail.records[0].Title != null)
    										tittle = dataAdapterCDetail.records[0].Title;
    									var tittlehtml = "<div style='margin: 10px;'><b>Tittle:</b> " + dataAdapterCDetail.records[0].Title + "</div>";
    									var suffix = ""
    									if (dataAdapterCDetail.records[0].Suffix != null)
    										suffix = dataAdapterCDetail.records[0].Suffix;
    									var suffixhtml = "<div style='margin: 10px;'><b>Suffix:</b> " + suffix + "</div>";
    									var ecvhtml = "<div style='margin: 10px;'><b>ECV:</b> " + dataAdapterCDetail.records[0].ECVFlag + "</div>";
    									var keyhtml = "<div style='margin: 10px;'><b>Keys:</b> " + dataAdapterCDetail.records[0].KeysFlag + "</div>";
    									var AuthorityHtml = "<div style='margin: 10px;'><b>Authority:</b> " + dataAdapterCDetail.records[0].AuthorityDescription + "</div>";
    									var relation = "";
    									if (dataAdapterCDetail.records[0].RelationDescription != null)
    										relation = dataAdapterCDetail.records[0].RelationDescription;
    									var relationhtml = "<div style='margin: 10px;'><b>Relation:</b> " + relation + "</div>";
    									var passcodehtml = "<div style='margin: 10px;'><b>Passcode:</b> " + dataAdapterCDetail.records[0].PIN + "</div>";
    									var effectivedate = "";
    									if (dataAdapterCDetail.records[0].EffectiveDate != null)
    										effectivedate = dataAdapterCDetail.records[0].EffectiveDate;
    									var effectivehtml = "<div style='margin: 10px;'><b>Effective Date:</b> " + dataAdapterCDetail.records[0].EffectiveDate + "</div>";
    									var expiredate = "";
    									if (dataAdapterCDetail.records[0].ExpireDate != null)
    										expiredate = dataAdapterCDetail.records[0].ExpireDate;
    									var expiredhtml = "<div style='margin: 10px;'><b>Expired Date:</b> " + dataAdapterCDetail.records[0].ExpireDate + "</div>";
    									var contactInfoHtml = "<div style='margin: 10px;'><b>Info:</b><textarea id='infoEditor'></textarea></div>";
    									$(leftcolumn).append(orderhtml);
    									$(leftcolumn).append(FirstNamehtml);
    									$(leftcolumn).append(MiddleInitialhtml);
    									$(leftcolumn).append(LastNamehtml);
    									$(leftcolumn).append(tittlehtml);
    									$(leftcolumn).append(suffixhtml);
    									$(leftcolumn).append(ecvhtml);
    									$(leftcolumn).append(keyhtml);
    									$(leftcolumn).append(passcodehtml);
    									$(leftcolumn).append(AuthorityHtml);
    									$(rightcolumn).append(contactInfoHtml);
    									$(rightcolumn).append(relationhtml);
    									$(rightcolumn).append(effectivehtml);
    									$(rightcolumn).append(expiredhtml);
    									$('#infoEditor').jqxEditor({ height: 100, tools: '', editable: false, theme: 'bootstrap' });
    									$('#infoEditor').jqxEditor('val', dataAdapterCDetail.records[0].ContactInfoHtml)
    								}
    							});
    
    							//Phones
    							ContactPhonesInfo = tabsdiv.find('.ContactPhonesInfo');
    							var title = tabsdiv.find('.ContactPhones');
    							title.text("Phones");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactPhonesInfo));
    							var centercolumn = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumn);
    							var gvContactPhones = '<div id="gvContactPhones"></div>';
    							$(centercolumn).append(gvContactPhones);
    							var sourcePhoneContact =
    								{
    									type: "POST",
    									url: '@Url.Action("LoadPhones", "Contact")',
    									data: { KeyNum: datarecord.KeyNum, KeyType: datarecord.KeyType },
    									dataType: "json",
    									datafields: [
    											{ name: 'PhoneNumber', type: 'string' },
    											{ name: 'Ext', type: 'string' },
    											{ name: 'PhoneType', type: 'string' },
    											{ name: 'PhoneTypeDescription', type: 'string' },
    											{ name: 'Comment', type: 'string' },
    											{ name: 'AdditionalDataFlag', type: 'bool' },
    											{ name: 'AutoNotifyFlag', type: 'bool' },
    											{ name: 'BadNumberComment', type: 'string' },
    											{ name: 'BadNumberFlag', type: 'bool' },
    											{ name: 'SeqNum', type: 'int' },
    											{ name: 'Title', type: 'string' }
    									],
    									addrow: function (rowid, rowdata, position, commit) {
    										var params = "{" + "'PhoneNumber':'" + rowdata.PhoneNumber + "'," + "'PhoneTypeD':'" + rowdata.PhoneType + "'," + "'Ext':'" + rowdata.Ext + "'," + "'AutoNotifyFlag':" + rowdata.AutoNotifyFlag + "," + "'Comment':'" + rowdata.Comment + "'}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("CreateNewContactPhone", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											cache: false,
    											success: function (data) {
    												if (data.Success == true) {
    													rowdata.AdditionalDataFlag = data.Obj.AdditionalDataFlag;
    													rowdata.BadNumberComment = data.Obj.BadNumberComment;
    													rowdata.BadNumberDate = data.Obj.BadNumberDate;
    													rowdata.SeqNum = data.Obj.SeqNum;
    													rowdata.Title = data.Obj.Title;
    													$("#lbNotificationSuccess").text("Phone Updated Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									updaterow: function (rowid, rowdata, commit) {
    										var rowOldData = $('#gvContactPhones').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'PhoneNumber':'" + rowdata.PhoneNumber + "'," + "'Ext':'" + rowdata.Ext + "'," + "'PhoneTypeD':'" + rowdata.PhoneType + "'," + "'AutoNotifyFlag':" + rowdata.AutoNotifyFlag + "," + "'BadNumberFlag':" + rowdata.BadNumberFlag + "," + "'Comment':'" + rowdata.Comment + "'," + "'SeqNum':" + rowOldData.SeqNum + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("UpdateContactPhone", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											cache: false,
    											success: function (data) {
    												if (data.Success == true) {
    													rowdata.AdditionalDataFlag = data.Obj.AdditionalDataFlag;
    													rowdata.BadNumberComment = data.Obj.BadNumberComment;
    													rowdata.SeqNum = data.Obj.SeqNum;
    													rowdata.Title = data.Obj.Title;
    													$("#lbNotificationSuccess").text("Phone Updated Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									deleterow: function (rowid, commit) {
    										var rowOldData = $('#gvContactPhones').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'SeqNum':" + rowOldData.SeqNum + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("DeleteContactPhone", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											cache: false,
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Phone Remove Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									}
    								};
    							var dataAdapterPhones = new $.jqx.dataAdapter(sourcePhoneContact);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							var editrow = -1;
    							var cellclass = function (row, columnfield, value, data) {
    								if (data.BadNumberFlag == true && columnfield != 'AutoNotifyFlag') {
    									return 'badphonegrid';
    								}
    							}
    							$("#gvContactPhones").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterPhones,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								filterable: true,
    								enableellipsis: true,
    								columnsresize: true,
    								showtoolbar: true,
    								rendertoolbar: function (toolbar) {
    									var me = this;
    									var container = $("<div style='margin: 5px;'></div>");
    									toolbar.append(container);
    									container.append('<input id="addContactPhone" type="button" value="Add New" />&nbsp;&nbsp;');
    									container.append('<input id="deleteContactPhone" type="button" value="Delete Row" />&nbsp;&nbsp;');
    									container.append('<input id="showScheduleContact" type="button" value="Show Schedule" />&nbsp;&nbsp;');
    									$("#addContactPhone").jqxButton({ theme: 'bootstrap', template: "primary" });
    									$("#deleteContactPhone").jqxButton({ theme: 'bootstrap', template: "warning" });
    									$("#showScheduleContact").jqxButton({ theme: 'bootstrap', template: "info" });
    									$("#addContactPhone").on('click', function () {
    										$("#tbContactPhoneCreatePhone").val('');
    										$("#tbContactPhoneCreateExt").val('');
    										$("#tbContactPhoneCreateComment").val('');
    										$("#cbContactPhoneCreatePhoneType").jqxComboBox('clearSelection');
    										$("#cbContactPhoneCreateAuto").jqxCheckBox('val', false);
    										var offset = $("#gvContactPhones").offset();
    										$("#popupWindowCreateContactPhone").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    										$("#popupWindowCreateContactPhone").jqxWindow('open');
    									});
    									$("#deleteContactPhone").on('click', function () {
    										if (confirm("Are you sure do you want delete?") == false)
    											return;
    										var selectedrowindex = $("#gvContactPhones").jqxGrid('getselectedrowindex');
    										var rowscount = $("#gvContactPhones").jqxGrid('getdatainformation').rowscount;
    										if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    											var id = $("#gvContactPhones").jqxGrid('getrowid', selectedrowindex);
    											var commit = $("#gvContactPhones").jqxGrid('deleterow', id);
    										}
    									});
    									$("#showScheduleContact").on('click', function () {
    									});
    								},
    								columns: [
    										{ text: 'Phone', datafield: 'PhoneNumber', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, cellclassname: cellclass },
    										{ text: 'Ext', datafield: 'Ext', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, cellclassname: cellclass },
    										{ text: 'Phone Type', datafield: 'PhoneTypeDescription', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, cellclassname: cellclass },
    										{ text: 'Auto', datafield: 'AutoNotifyFlag', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, columntype: 'checkbox', cellclassname: cellclass },
    										{ text: 'Bad#', datafield: 'BadNumberFlag', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, columntype: 'checkbox', cellclassname: cellclass },
    										{
    											text: 'Edit', datafield: 'Edit', width: 40, columntype: 'button', cellsrenderer: function () {
    												return 'Edit';
    											}, buttonclick: function (row) {
    												editrow = row;
    												var offset = $("#gvContactPhones").offset();
    												$("#popupWindowEditContactPhone").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    												var dataRecord = $("#gvContactPhones").jqxGrid('getrowdata', editrow);
    												$("#tbContactPhoneEditPhone").jqxInput('val', dataRecord.PhoneNumber);
    												$("#tbContactPhoneEditExt").jqxInput('val', dataRecord.Ext);
    												$("#tbContactPhoneEditComment").jqxInput('val', dataRecord.Comment);
    												var item = $("#cbContactPhoneEditPhoneType").jqxComboBox('getItemByValue', dataRecord.PhoneType);
    												$("#cbContactPhoneEditPhoneType").jqxComboBox('selectItem', item);
    												$("#cbContactPhoneEditAuto").jqxCheckBox('val', dataRecord.AutoNotifyFlag);
    												$("#cbContactPhoneEditBadNumber").jqxCheckBox('val', dataRecord.BadNumberFlag);
    												$("#popupWindowEditContactPhone").jqxWindow('open');
    											}
    										}
    								]
    							});
    							$("#btSaveCreateContactPhone").click(function () {
    								var phonenumbervalue = $("#tbContactPhoneCreatePhone").val();
    								var phoneextensionvalue = $("#tbContactPhoneCreateExt").val();
    								var commenvalue = $("#tbContactPhoneCreateComment").val();
    								var phonetypeitemvalue = $("#cbContactPhoneCreatePhoneType").jqxComboBox('val');
    								var item = $("#cbContactPhoneCreatePhoneType").jqxComboBox('getItemByValue', phonetypeitemvalue);
    								var autovalue = $("#cbContactPhoneCreateAuto").jqxCheckBox('val');
    								var row = { PhoneNumber: phonenumbervalue, Ext: phoneextensionvalue, PhoneType: phonetypeitemvalue, PhoneTypeDescription: item.label, AdditionalDataFlag: null, AutoNotifyFlag: autovalue, BadNumberComment: '', BadNumberFlag: false, SeqNum: null, Title: '', Comment: commenvalue };
    								var commit = $('#gvContactPhones').jqxGrid('addrow', null, row);
    								$("#popupWindowCreateContactPhone").jqxWindow('hide');
    							});
    							$("#popupWindowEditContactPhone").on('open', function () {
    								$("#tbContactPhoneEditPhone").jqxInput('selectAll');
    							});
    							$("#btSaveEditContactPhone").click(function () {
    								if (editrow >= 0) {
    									var phonenumbervalue = $("#tbContactPhoneEditPhone").val();
    									var phoneextensionvalue = $("#tbContactPhoneEditExt").val();
    									var commenvalue = $("#tbContactPhoneEditComment").val();
    									var phonetypeitemvalue = $("#cbContactPhoneEditPhoneType").jqxComboBox('val');
    									var item = $("#cbContactPhoneEditPhoneType").jqxComboBox('getItemByValue', phonetypeitemvalue);
    									var autovalue = $("#cbContactPhoneEditAuto").jqxCheckBox('val');
    									var badnumbervalue = $("#cbContactPhoneEditBadNumber").jqxCheckBox('val');
    									var row = { PhoneNumber: phonenumbervalue, Ext: phoneextensionvalue, PhoneType: phonetypeitemvalue, PhoneTypeDescription: item.label, AdditionalDataFlag: null, AutoNotifyFlag: autovalue, BadNumberComment: '', BadNumberFlag: badnumbervalue, SeqNum: null, Title: '', Comment: commenvalue };
    									var commit = $('#gvContactPhones').jqxGrid('updaterow', editrow, row);
    									$("#popupWindowEditContactPhone").jqxWindow('hide');
    								}
    							});
    							//Emails
    							var title = tabsdiv.find('.ContactEmails');
    							title.text("Emails");
    							ContactEmailInfo = tabsdiv.find('.ContactEmailsInfo');
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactEmailInfo));
    							var centercolumnHol = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumnHol);
    							var gvContactEmail = '<div id="gvContactEmail"></div>';
    							$(centercolumnHol).append(gvContactEmail);
    							var sourceEmailContact =
    								{
    									type: "POST",
    									url: '@Url.Action("LoadEmails", "Contact")',
    									data: { KeyNum: datarecord.ContactNum, KeyType: "Contact" },
    									dataType: "json",
    									async: false,
    									cache: false,
    									datafields: [
    										 { name: 'AutoNotifyFlag', type: 'bool' },
    										 { name: 'DataChangeNotifyFlag', type: 'bool' },
    										 { name: 'EmailAddress', type: 'string' },
    										 { name: 'KeyNum', type: 'int' },
    										 { name: 'KeyType', type: 'string' },
    										 { name: 'SeqNum', type: 'int' },
    										 { name: 'Title', type: 'string' }
    									],
    									addrow: function (rowid, rowdata, position, commit) {
    									    var params = "{" + "'KeyNum':" + datarecord.ContactNum + "," + "'KeyType':'" + "Contact" + "'," + "'AutoNotifyFlag':" + rowdata.AutoNotifyFlag + "," + "'email':'" + rowdata.EmailAddress + "'," + "'auto':" + rowdata.AutoNotifyFlag + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("CreateEmail", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											cache: false,
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Email Created Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													UpdateContactEmailGrid(datarecord.ContactNum);
    													commit(false);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									updaterow: function (rowid, rowdata, commit) {
    										var rowOldData = $('#gvContactEmail').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.ContactNum + "," + "'KeyType':'" + "Contact" + "'," + "'SeqNum':" + rowOldData.SeqNum + "," + "'email':'" + rowdata.EmailAddress + "'," + "'auto':" + rowdata.AutoNotifyFlag + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("UpdateEmail", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											cache: false,
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Email Updated Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													UpdateContactEmailGrid(datarecord.ContactNum);
    													commit(false);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    								    deleterow: function (rowid, commit) {
    										var rowOldData = $('#gvContactEmail').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.ContactNum + "," + "'KeyType':'" + "Contact" + "'," + "'SeqNum':" + rowOldData.SeqNum + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("DeleteEmail", "Contact")',
    										    data: params,
    										    cache: false,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Email Remove Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													UpdateContactEmailGrid(datarecord.ContactNum);
    													commit(false);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									}
    								};
    							var dataAdapterEmail = new $.jqx.dataAdapter(sourceEmailContact);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							var editrow = -1;
    							$("#gvContactEmail").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterEmail,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								filterable: true,
    								enableellipsis: true,
    								columnsresize: true,
    								showtoolbar: true,
    								rendertoolbar: function (toolbar) {
    									var me = this;
    									var container = $("<div style='margin: 5px;'></div>");
    									toolbar.append(container);
    									container.append('<input id="addContactEmail" type="button" value="Add New" />&nbsp;&nbsp;');
    									container.append('<input id="deleteContactEmail" type="button" value="Delete Row" />&nbsp;&nbsp;');
    									$("#addContactEmail").jqxButton({ theme: 'bootstrap', template: "primary" });
    									$("#deleteContactEmail").jqxButton({ theme: 'bootstrap', template: "warning" });
    									$("#addContactEmail").on('click', function () {
    										$("#tbContactEmailCreateEmail").val('');
    										$("#cbContactEmailCreateAuto").jqxCheckBox('val', false);
    										$("#cbContactEmailCreateData").jqxCheckBox('val', false);
    										var offset = $("#gvContactEmail").offset();
    										$("#popupWindowCreateContactEmail").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    										$("#popupWindowCreateContactEmail").jqxWindow('open');
    									});
    									$("#deleteContactEmail").on('click', function () {
    										if (confirm("Are you sure do you want delete?") == false)
    											return;
    										var selectedrowindex = $("#gvContactEmail").jqxGrid('getselectedrowindex');
    										var rowscount = $("#gvContactEmail").jqxGrid('getdatainformation').rowscount;
    										if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    											var id = $("#gvContactEmail").jqxGrid('getrowid', selectedrowindex);
    											var commit = $("#gvContactEmail").jqxGrid('deleterow', id);
    										}
    									});
    								},
    								columns: [
    										{ text: 'Email', datafield: 'EmailAddress', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'Auto', datafield: 'AutoNotifyFlag', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, columntype: 'checkbox' },
    										{ text: 'Data', datafield: 'DataChangeNotifyFlag', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, columntype: 'checkbox' },
    										 {
    											 text: 'Edit', datafield: 'Edit', width: 40, columntype: 'button', cellsrenderer: function () {
    												 return 'Edit';
    											 }, buttonclick: function (row) {
    												 editrow = row;
    												 var offset = $("#gvContactEmail").offset();
    												 $("#popupWindowEditContactEmail").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    												 var dataRecord = $("#gvContactEmail").jqxGrid('getrowdata', editrow);
    												 $("#tbContactEmailEditEmail").jqxInput('val', dataRecord.EmailAddress);
    												 $("#cbContactEmailEditAuto").jqxCheckBox('val', dataRecord.AutoNotifyFlag);
    												 $("#cbContactEmailEditData").jqxCheckBox('val', dataRecord.DataChangeNotifyFlag);
    												 $("#popupWindowEditContactEmail").jqxWindow('open');
    											 }
    										 }
    								]
    							});
    							$("#btSaveCreateContactEmail").click(function () {
    								var emailAddress = $("#tbContactEmailCreateEmail").val();
    								var autovalue = $("#cbContactEmailCreateAuto").jqxCheckBox('val');
    								var datavalue = $("#cbContactEmailCreateData").jqxCheckBox('val');
    								var row = { AutoNotifyFlag: autovalue, DataChangeNotifyFlag: datavalue, EmailAddress: emailAddress, KeyNum: null, KeyType: null, SeqNum: null, Title: '' };
    								var commit = $('#gvContactEmail').jqxGrid('addrow', null, row);
    								$("#popupWindowCreateContactEmail").jqxWindow('hide');
    							});
    							$("#popupWindowEditContactEmail").on('open', function () {
    								$("#tbContactEmailEditEmail").jqxInput('selectAll');
    							});
    							$("#btSaveEditContactEmail").click(function () {
    								if (editrow >= 0) {
    									var emailAddress = $("#tbContactEmailEditEmail").val();
    									var autovalue = $("#cbContactEmailEditAuto").jqxCheckBox('val');
    									var datavalue = $("#cbContactEmailEditData").jqxCheckBox('val');
    									var row = { AutoNotifyFlag: autovalue, DataChangeNotifyFlag: datavalue, EmailAddress: emailAddress, KeyNum: null, KeyType: null, SeqNum: null, Title: '' };
    									var commit = $('#gvContactEmail').jqxGrid('updaterow', editrow, row);
    									$("#popupWindowEditContactEmail").jqxWindow('hide');
    								}
    							});
    							//Contact List Member
    							ContactListMemberInfo = tabsdiv.find('.ContactListMemberInfo');
    							var title = tabsdiv.find('.ContactListMember');
    							title.text("Contact List");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactListMemberInfo));
    							var centercolumn = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumn);
    							var gvContactListMember = '<div id="gvContactListMember"></div>';
    							$(centercolumn).append(gvContactListMember);
    							var sourceContactListMember =
    								{
    									type: "POST",
    									url: '@Url.Action("LoadContactListMember", "Contact")',
    									data: { KeyNum: datarecord.KeyNum, KeyType: datarecord.KeyType, ContactNum: datarecord.ContactNum },
    									dataType: "json",
    									datafields: [
    										 { name: 'ContactListType', type: 'string' },
    										 { name: 'ContactListTypeDescription', type: 'bool' },
    										 { name: 'ContactNum', type: 'int' },
    										 { name: 'KeyNum', type: 'int' },
    										 { name: 'KeyType', type: 'string' },
    										 { name: 'SeqNum', type: 'int' }
    									]
    								};
    							var dataAdapterListMember = new $.jqx.dataAdapter(sourceContactListMember);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							var editrow = -1;
    							$("#gvContactListMember").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterListMember,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								enableellipsis: true,
    								filterable: true,
    								columnsresize: true,
    								columns: [
    										{ text: 'Type', datafield: 'ContactListType', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'Description', datafield: 'ContactListTypeDescription', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'Order#', datafield: 'SeqNum', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer }
    								]
    							});
    							//Passcodes
    							ContactPasscodesInfo = tabsdiv.find('.ContactPasscodesInfo');
    							var title = tabsdiv.find('.ContactPasscodes');
    							title.text("Passcodes");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactPasscodesInfo));
    							var centercolumn = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumn);
    							var gvContactPasscode = '<div id="gvContactPasscode"></div>';
    							$(centercolumn).append(gvContactPasscode);
    							var sourceContactPasscode =
    								{
    									type: "POST",
    									url: '@Url.Action("LoadPINList", "Contact")',
    									data: { KeyNum: datarecord.KeyNum, KeyType: datarecord.KeyType, ContactNum: datarecord.ContactNum },
    									dataType: "json",
    									cache: false,
    									datafields: [
    										 { name: 'ContactNum', type: 'int' },
    										 { name: 'KeyNum', type: 'int' },
    										 { name: 'KeyType', type: 'string' },
    										 { name: 'PIN', type: 'string' },
    										 { name: 'SeqNum', type: 'int' }
    									],
    									addrow: function (rowid, rowdata, position, commit) {
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'PIN':'" + rowdata.PIN + "'}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("CreateNewPIN", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											cache: false,
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													rowdata.SeqNum = data.Obj.SeqNum;
    													$("#lbNotificationSuccess").text("PIN Created Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									updaterow: function (rowid, rowdata, commit) {
    										var rowOldData = $('#gvContactPasscode').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'PIN':'" + rowdata.PIN + "'," + "'SeqNum':" + rowOldData.SeqNum + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("UpdatePIN", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											cache: false,
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													rowdata.SeqNum = data.Obj.SeqNum;
    													$("#lbNotificationSuccess").text("PIN Updated Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									deleterow: function (rowid, commit) {
    										var rowOldData = $('#gvContactPasscode').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'SeqNum':" + rowOldData.SeqNum + "}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("DeletePIN", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											cache: false,
    											dataType: "json",
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("PIN Remove Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													commit(true);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									}
    								};
    							var dataAdapterPasscode = new $.jqx.dataAdapter(sourceContactPasscode);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							var editrow = -1;
    							$("#gvContactPasscode").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterPasscode,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								filterable: true,
    								columnsresize: true,
    								enableellipsis: true,
    								showtoolbar: true,
    								rendertoolbar: function (toolbar) {
    									var me = this;
    									var container = $("<div style='margin: 5px;'></div>");
    									toolbar.append(container);
    									container.append('<input id="addContactPasscode" type="button" value="Add New" />&nbsp;&nbsp;');
    									container.append('<input id="deleteContactPasscode" type="button" value="Delete Row" />&nbsp;&nbsp;');
    									$("#addContactPasscode").jqxButton({ theme: 'bootstrap', template: "primary" });
    									$("#deleteContactPasscode").jqxButton({ theme: 'bootstrap', template: "warning" });
    									$("#addContactPasscode").on('click', function () {
    										$("#tbContactPasscodeCreatePIN").val('');
    										var offset = $("#gvContactPasscode").offset();
    										$("#popupWindowCreateContactPasscode").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    										$("#popupWindowCreateContactPasscode").jqxWindow('open');
    									});
    									$("#deleteContactPasscode").on('click', function () {
    										if (confirm("Are you sure do you want delete?") == false)
    											return;
    										var selectedrowindex = $("#gvContactPasscode").jqxGrid('getselectedrowindex');
    										var rowscount = $("#gvContactPasscode").jqxGrid('getdatainformation').rowscount;
    										if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    											var id = $("#gvContactPasscode").jqxGrid('getrowid', selectedrowindex);
    											var commit = $("#gvContactPasscode").jqxGrid('deleterow', id);
    										}
    									});
    								},
    								columns: [
    										{ text: 'PIN', datafield: 'PIN', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'Order#', datafield: 'SeqNum', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{
    											text: 'Edit', datafield: 'Edit', width: 40, columntype: 'button', cellsrenderer: function () {
    												return 'Edit';
    											}, buttonclick: function (row) {
    												editrow = row;
    												var offset = $("#gvContactPasscode").offset();
    												$("#popupWindowEditContactPasscode").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    												var dataRecord = $("#gvContactPasscode").jqxGrid('getrowdata', editrow);
    												$("#tbContactPasscodeEditPIN").jqxInput('val', dataRecord.PIN);
    												$("#popupWindowEditContactPasscode").jqxWindow('open');
    											}
    										}
    								]
    							});
    							$("#btSaveCreateContactPasscode").click(function () {
    								var pinvalue = $("#tbContactPasscodeCreatePIN").val();
    								var row = { ContactNum: null, KeyNum: null, KeyType: '', PIN: pinvalue, SeqNum: null };
    								var commit = $('#gvContactPasscode').jqxGrid('addrow', null, row);
    								$("#popupWindowCreateContactPasscode").jqxWindow('hide');
    							});
    							$("#popupWindowEditContactPasscode").on('open', function () {
    								$("#tbContactPasscodeEditPIN").jqxInput('selectAll');
    							});
    							$("#btSaveEditContactPasscode").click(function () {
    								if (editrow >= 0) {
    									var pinvalue = $("#tbContactPasscodeEditPIN").val();
    									var row = { ContactNum: null, KeyNum: null, KeyType: '', PIN: pinvalue, SeqNum: null };
    									var commit = $('#gvContactPasscode').jqxGrid('updaterow', editrow, row);
    									$("#popupWindowEditContactPasscode").jqxWindow('hide');
    								}
    							});
    							//UserIds
    							ContactUserIdInfo = tabsdiv.find('.ContactUserIdInfo');
    							var title = tabsdiv.find('.ContactUserId');
    							title.text("User IDs");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactUserIdInfo));
    							var centercolumn = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumn);
    							var gvContactUser = '<div id="gvContactUser"></div>';
    							$(centercolumn).append(gvContactUser);
    							var sourceContactUser =
    									{
    										type: "POST",
    										url: '@Url.Action("LoadListUserId", "Contact")',
    										data: { ContactNum: datarecord.ContactNum },
    										dataType: "json",
    										cache: false,
    										datafields: [
    											 { name: 'ContactNum', type: 'int' },
    											 { name: 'SiteNum', type: 'int' },
    											 { name: 'TransmitterCode', type: 'string' },
    											 { name: 'UserIDI', type: 'string' }
    										],
    										addrow: function (rowid, rowdata, position, commit) {
    											var params = "{" + "'ContactNum':" + datarecord.ContactNum + "," + "'SystemNumber':'" + rowdata.TransmitterCode + "'," + "'userid':'" + rowdata.UserIDI + "'}";
    											$.ajax({
    												type: "POST",
    												url: '@Url.Action("CreateNewUserId", "Contact")',
    												data: params,
    												contentType: "application/json; charset=utf-8",
    												dataType: "json",
    												cache: false,
    												success: function (data) {
    													if (data.Success == true) {
    														rowdata.ContactNum = data.Obj.ContactNum;
    														rowdata.SiteNum = data.Obj.SiteNum;
    														$("#lbNotificationSuccess").text("UserID Created Successfully");
    														$("#jqxNotificationSuccess").jqxNotification("open");
    														commit(true);
    													}
    													else {
    														$("#lbNotification").text("An error occured. " + data.Message);
    														$("#jqxNotification").jqxNotification("open");
    														commit(false);
    													}
    												}
    											});
    										},
    										updaterow: function (rowid, rowdata, commit) {
    											var rowOldData = $('#gvContactUser').jqxGrid('getrowdata', rowid);
    											var params = "{" + "'oldUserId':'" + rowOldData.UserIDI + "'," + "'oldTrasmitter':'" + rowOldData.TransmitterCode + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'SystemNumber':'" + rowdata.TransmitterCode + "'," + "'userid':'" + rowdata.UserIDI + "'}";
    											$.ajax({
    												type: "POST",
    												url: '@Url.Action("UpdateUserId", "Contact")',
    												data: params,
    												contentType: "application/json; charset=utf-8",
    												dataType: "json",
    												cache: false,
    												success: function (data) {
    													if (data.Success == true) {
    														rowdata.ContactNum = data.Obj.ContactNum;
    														rowdata.SiteNum = data.Obj.SiteNum;
    														$("#lbNotificationSuccess").text("UserID Updated Successfully");
    														$("#jqxNotificationSuccess").jqxNotification("open");
    														commit(true);
    													}
    													else {
    														$("#lbNotification").text("An error occured. " + data.Message);
    														$("#jqxNotification").jqxNotification("open");
    														commit(false);
    													}
    												}
    											});
    										},
    										deleterow: function (rowid, commit) {
    											var rowOldData = $('#gvContactUser').jqxGrid('getrowdata', rowid);
    											var params = "{" + "'ContactNum':" + datarecord.ContactNum + "," + "'SystemNumber':'" + rowOldData.TransmitterCode + "'," + "'userid':'" + rowOldData.UserIDI + "'}";
    											$.ajax({
    												type: "POST",
    												url: '@Url.Action("DeleteUserId", "Contact")',
    												data: params,
    												contentType: "application/json; charset=utf-8",
    												dataType: "json",
    												cache: false,
    												success: function (data) {
    													if (data.Success == true) {
    														$("#lbNotificationSuccess").text("UserID Remove Successfully");
    														$("#jqxNotificationSuccess").jqxNotification("open");
    														commit(true);
    													}
    													else {
    														$("#lbNotification").text("An error occured. " + data.Message);
    														$("#jqxNotification").jqxNotification("open");
    														commit(false);
    													}
    												}
    											});
    										}
    									};
    							var dataAdapterUser = new $.jqx.dataAdapter(sourceContactUser);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							var editrow = -1;
    							$("#gvContactUser").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterUser,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								filterable: true,
    								enableellipsis: true,
    								columnsresize: true,
    								showtoolbar: true,
    								rendertoolbar: function (toolbar) {
    									var me = this;
    									var container = $("<div style='margin: 5px;'></div>");
    									toolbar.append(container);
    									container.append('<input id="addContactUser" type="button" value="Add New" />&nbsp;&nbsp;');
    									container.append('<input id="deleteContactUser" type="button" value="Delete Row" />&nbsp;&nbsp;');
    									$("#addContactUser").jqxButton({ theme: 'bootstrap', template: "primary" });
    									$("#deleteContactUser").jqxButton({ theme: 'bootstrap', template: "warning" });
    									$("#addContactUser").on('click', function () {
    										$("#tbContactUserCreateUserID").val('');
    										$("#cbContactUserCreateSystemNumber").jqxComboBox('clearSelection');
    										var offset = $("#gvContactUser").offset();
    										$("#popupWindowCreateUserID").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    										$("#popupWindowCreateUserID").jqxWindow('open');
    									});
    									$("#deleteContactUser").on('click', function () {
    										if (confirm("Are you sure do you want delete?") == false)
    											return;
    										var selectedrowindex = $("#gvContactUser").jqxGrid('getselectedrowindex');
    										var rowscount = $("#gvContactUser").jqxGrid('getdatainformation').rowscount;
    										if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    											var id = $("#gvContactUser").jqxGrid('getrowid', selectedrowindex);
    											var commit = $("#gvContactUser").jqxGrid('deleterow', id);
    										}
    									});
    								},
    								columns: [
    										{ text: 'User ID', datafield: 'UserIDI', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'System#', datafield: 'TransmitterCode', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										 {
    											 text: 'Edit', datafield: 'Edit', width: 40, columntype: 'button', cellsrenderer: function () {
    												 return 'Edit';
    											 }, buttonclick: function (row) {
    												 editrow = row;
    												 var offset = $("#gvContactUser").offset();
    												 $("#popupWindowEditUserID").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    												 var dataRecord = $("#gvContactUser").jqxGrid('getrowdata', editrow);
    												 $("#tbContactUserEditUserID").jqxInput('val', dataRecord.UserIDI);
    												 var item = $("#cbContactUserEditSystemNumber").jqxComboBox('getItemByValue', dataRecord.TransmitterCode);
    												 $("#cbContactUserEditSystemNumber").jqxComboBox('selectItem', item);
    												 $("#popupWindowEditUserID").jqxWindow('open');
    											 }
    										 }
    								]
    							});
    							$("#btSaveCreateContactUserId").click(function () {
    								var userid = $("#tbContactUserCreateUserID").val();
    								var systemNumber = $("#cbContactUserCreateSystemNumber").jqxComboBox('val');
    								var row = { ContactNum: null, SiteNum: null, TransmitterCode: systemNumber, UserIDI: userid };
    								var commit = $('#gvContactUser').jqxGrid('addrow', null, row);
    								$("#popupWindowCreateUserID").jqxWindow('hide');
    							});
    							$("#popupWindowEditUserID").on('open', function () {
    								$("#cbContactUserEditSystemNumber").jqxComboBox('focus');
    							});
    							$("#btSaveEditContactUserId").click(function () {
    								if (editrow >= 0) {
    									var userid = $("#tbContactUserEditUserID").val();
    									var systemNumber = $("#cbContactUserEditSystemNumber").jqxComboBox('val');
    									var row = { ContactNum: null, SiteNum: null, TransmitterCode: systemNumber, UserIDI: userid };
    									var commit = $('#gvContactUser').jqxGrid('updaterow', editrow, row);
    									$("#popupWindowEditUserID").jqxWindow('hide');
    								}
    							});
    
    							//Temp Deactivate
    							ContactTempDeactivateInfo = tabsdiv.find('.ContactTempDeactivateInfo');
    							var title = tabsdiv.find('.ContactTempDeactivate');
    							title.text("Deactivate");
    							var container = $('<div style="margin: 5px;"></div>')
    							container.appendTo($(ContactTempDeactivateInfo));
    							var centercolumn = $('<div style="float: left; width: 100%;"></div>');
    							container.append(centercolumn);
    							var gvContactTempDeactivate = '<div id="gvContactTemp"></div>';
    							$(centercolumn).append(gvContactTempDeactivate);
    							var sourceTemporalDeactivate =
    								{
    									type: "POST",
    									url: '@Url.Action("TemporalDeactivateList", "Contact")',
    									data: { KeyNum: datarecord.KeyNum, KeyType: datarecord.KeyType, ContactNum: datarecord.ContactNum },
    									dataType: "json",
    									async: false,
    									cache: false,
    									datafields: [
    												{ name: 'ContactNum', type: 'int' },
    												{ name: 'EndDate', type: 'date', format: "M/d/yyyy H:mm" },
    												{ name: 'EndTime', type: 'string' },
    												{ name: 'InactiveEndDate', type: 'date', format: "M/d/yyyy H:mm" },
    												{ name: 'InactiveStartDate', type: 'date', format: "M/d/yyyy H:mm" },
    												{ name: 'KeyNum', type: 'int' },
    												{ name: 'KeyType', type: 'string' },
    												{ name: 'StartDate', type: 'date', format: "M/d/yyyy H:mm" },
    												{ name: 'StartTime', type: 'string' }
    									],
    									beforeLoadComplete: function (records) {
    										for (var i = 0; i < records.length; i++) {
    											if (records[i].EndDate != null) {
    												var date = new Date(records[i].EndDate);
    												var mil = date.getTime();
    												var time = parseInt(mil);
    												records[i].EndDate = new Date(parseInt(time) + new Date(time).getTimezoneOffset() * 60000);
    											}
    											if (records[i].InactiveEndDate != null) {
    												var date = new Date(records[i].InactiveEndDate);
    												var mil = date.getTime();
    												var time = parseInt(mil);
    												records[i].InactiveEndDate = new Date(parseInt(time) + new Date(time).getTimezoneOffset() * 60000);
    											};
    											if (records[i].InactiveStartDate != null) {
    												var date = new Date(records[i].InactiveStartDate);
    												var mil = date.getTime();
    												var time = parseInt(mil);
    												records[i].InactiveStartDate = new Date(parseInt(time) + new Date(time).getTimezoneOffset() * 60000);
    											};
    											if (records[i].StartDate != null) {
    												var date = new Date(records[i].StartDate);
    												var mil = date.getTime();
    												var time = parseInt(mil);
    												records[i].StartDate = new Date(parseInt(time) + new Date(time).getTimezoneOffset() * 60000);
    											};
    										}
    										return records;
    									},
    									addrow: function (rowid, rowdata, position, commit) {
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'StartDate':'" + rowdata.StartDate.toDateString() + "'," + "'StartTime':'" + rowdata.StartTime + "'," + "'EndDate':'" + rowdata.EndDate.toDateString() + "'," + "'EndTime':'" + rowdata.EndTime + "'}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("CreateNewTemporalDeactivate", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											cache: false,
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Temp. Deactivate Created Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													UpdateTempDeactivate(datarecord.KeyNum, datarecord.KeyType, datarecord.ContactNum);
    													commit(false);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									},
    									deleterow: function (rowid, commit) {
    										var rowOldData = $('#gvContactTemp').jqxGrid('getrowdata', rowid);
    										var params = "{" + "'KeyNum':" + datarecord.KeyNum + "," + "'KeyType':'" + datarecord.KeyType + "'," + "'ContactNum':" + datarecord.ContactNum + "," + "'StartDate':'" + rowOldData.StartDate.toDateString() + "'," + "'StartTime':'" + rowOldData.StartTime + "'," + "'EndDate':'" + rowOldData.EndDate.toDateString() + "'," + "'EndTime':'" + rowOldData.EndTime + "'}";
    										$.ajax({
    											type: "POST",
    											url: '@Url.Action("DeleteTemporalDeactivate", "Contact")',
    											data: params,
    											contentType: "application/json; charset=utf-8",
    											dataType: "json",
    											cache: false,
    											success: function (data) {
    												if (data.Success == true) {
    													$("#lbNotificationSuccess").text("Temp. Deactivate Remove Successfully");
    													$("#jqxNotificationSuccess").jqxNotification("open");
    													UpdateTempDeactivate(datarecord.KeyNum, datarecord.KeyType, datarecord.ContactNum);
    													commit(false);
    												}
    												else {
    													$("#lbNotification").text("An error occured. " + data.Message);
    													$("#jqxNotification").jqxNotification("open");
    													commit(false);
    												}
    											}
    										});
    									}
    								};
    							var dataAdapterTemp = new $.jqx.dataAdapter(sourceTemporalDeactivate);
    							var tooltiprenderer = function (element) {
    								$(element).jqxTooltip({ position: 'mouse', content: $(element).text(), theme: 'bootstrap' });
    							}
    							$("#gvContactTemp").jqxGrid({
    								width: "100%",
    								theme: 'bootstrap',
    								source: dataAdapterTemp,
    								altrows: true,
    								sortable: true,
    								selectionmode: 'singlerow',
    								pageable: true,
    								pagesize: 20,
    								enableellipsis: true,
    								filterable: true,
    								columnsresize: true,
    								showtoolbar: true,
    								rendertoolbar: function (toolbar) {
    									var me = this;
    									var container = $("<div style='margin: 5px;'></div>");
    									toolbar.append(container);
    									container.append('<input id="addContactTemp" type="button" value="Add New" />&nbsp;&nbsp;');
    									container.append('<input id="deleteContactTemp" type="button" value="Delete Row" />&nbsp;&nbsp;');
    									$("#addContactTemp").jqxButton({ theme: 'bootstrap', template: "primary" });
    									$("#deleteContactTemp").jqxButton({ theme: 'bootstrap', template: "warning" });
    									$("#addContactTemp").on('click', function () {
    										$("#tbContactTempCreateStartDate").val(null);
    										$("#tbContactTempCreateEndDate").val(null);
    										var offset = $("#gvContactTemp").offset();
    										$("#popupWindowCreateTemp").jqxWindow({ position: { x: parseInt(offset.left) + 60, y: parseInt(offset.top) + 60 } });
    										$("#popupWindowCreateTemp").jqxWindow('open');
    									});
    									$("#deleteContactTemp").on('click', function () {
    										if (confirm("Are you sure do you want delete?") == false)
    											return;
    										var selectedrowindex = $("#gvContactTemp").jqxGrid('getselectedrowindex');
    										var rowscount = $("#gvContactTemp").jqxGrid('getdatainformation').rowscount;
    										if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    											var id = $("#gvContactTemp").jqxGrid('getrowid', selectedrowindex);
    											var commit = $("#gvContactTemp").jqxGrid('deleterow', id);
    										}
    									});
    								},
    								columns: [
    										{ text: 'Start Date', datafield: 'StartDate', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, cellsformat: "M/d/yyyy" },
    										{ text: 'Start Time', datafield: 'StartTime', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer },
    										{ text: 'End Date', datafield: 'EndDate', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer, cellsformat: "M/d/yyyy" },
    										{ text: 'End Time', datafield: 'EndTime', sortable: true, groupable: true, exportable: true, rendered: tooltiprenderer }
    								]
    							});

    That is not a complete function but actually the problem is repeating in all the tabs that I made the event adrow for the grid,
    Just note that in the vent addrow, or update or delete I’m refreshing the grid data assigning a new datasource, you could see when I’m calling the function (example): UpdateTempDeactivate(datarecord.KeyNum, datarecord.KeyType, datarecord.ContactNum);

    Thank you very much I appreciate it a lot!!
    Jose

    Grid rowdetail and Insert #68427

    jperera
    Participant

    Sorry, you could check for example in the variable initrowdetails the comment //Email I load all the information for the tab email and this is one of the insert with issue!!
    Sorry for the large code but it is a big function

    Grid rowdetail and Insert #68436

    jperera
    Participant

    Another important thing, when I execute any action of update, delete or insert in any detailrow and I went to another detail row and try to update for example the method: var dataRecord = $(“#gvContactEmail”).jqxGrid(‘getrowdata’, editrow);
    don’t get any data too!!,
    I think it is a bug!!!

    Grid rowdetail and Insert #68452

    Dimitar
    Participant

    Hi jperera,

    Your code is far too extensive for us to check thoroughly. Please try to weed the issue out and reproduce it on a smaller scale (e.g. in a JSFiddle).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

    Grid rowdetail and Insert #68467

    jperera
    Participant

    Thanks Dimitar, I will do and I post it here to you could analyze it…

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.