You need to sign in to do that
Don't have an account?
Vishwas B N
Properties defaulting to its original values
Hi team,
I have a navigation from one app page(let A) to another app page((let B) and back to original page.
When i navigate to page B, i store current value of the properties to localstorage. When i comeback to page A i get the value form the local storage and set it to the property, but when i call a function the property values are defaulted to the original values.
Can you please help me how can i retain the assigned values.
Below are the code snippet(LWC):
connectedCallback() {
loadStyle(this, HideLightningHeader);
this.setdepartmentvalues();
this.decideview();
}
decideview() {
var scheduledata = JSON.parse(localStorage.getItem('scheduledata'));
if (scheduledata == undefined || scheduledata == null) { // works when page loaded for first time
this.loadscheduleboarddata();
}
else { // this works whn navigated from page B to page A
this.selectedbustype = scheduledata.selectedbustype; //new assigned value
this.selectedcustomer = scheduledata.selectedcustomer; //new assigned value
this.selectedDate = scheduledata.selectedDate; //new assigned value
this.selectedpropulsion = scheduledata.selectedpropulsion; //new assigned value
this.selectedbusstatus = scheduledata.selectedbusstatus; //new assigned value
this.partShortageFilter = scheduledata.partShortageFilter; //new assigned value
this.discrepancyFilter = scheduledata.discrepancyFilter; //new assigned value
localStorage.removeItem('scheduledata');
this.handleallFilterchanges();
}
}
handleallFilterchanges(event) {
var selectedbustype = this.selectedBusType; //value defaulted to original
var selectedcustomer = this.selectedCustomer; //value defaulted to original
var selectedDate = this.dateFieldValue; //value defaulted to original
var selectedpropulsion = this.selectedBusPropulsion; //value defaulted to original
var selectedbusstatus = this.selectedBusStatus; //value defaulted to original
var partShortageFilter = this.partShortageFilter; //value defaulted to original
var discrepancyFilter = this.discrepancyFilter; //value defaulted to original
//other code for logic
.
.
.
}
I have a navigation from one app page(let A) to another app page((let B) and back to original page.
When i navigate to page B, i store current value of the properties to localstorage. When i comeback to page A i get the value form the local storage and set it to the property, but when i call a function the property values are defaulted to the original values.
Can you please help me how can i retain the assigned values.
Below are the code snippet(LWC):
connectedCallback() {
loadStyle(this, HideLightningHeader);
this.setdepartmentvalues();
this.decideview();
}
decideview() {
var scheduledata = JSON.parse(localStorage.getItem('scheduledata'));
if (scheduledata == undefined || scheduledata == null) { // works when page loaded for first time
this.loadscheduleboarddata();
}
else { // this works whn navigated from page B to page A
this.selectedbustype = scheduledata.selectedbustype; //new assigned value
this.selectedcustomer = scheduledata.selectedcustomer; //new assigned value
this.selectedDate = scheduledata.selectedDate; //new assigned value
this.selectedpropulsion = scheduledata.selectedpropulsion; //new assigned value
this.selectedbusstatus = scheduledata.selectedbusstatus; //new assigned value
this.partShortageFilter = scheduledata.partShortageFilter; //new assigned value
this.discrepancyFilter = scheduledata.discrepancyFilter; //new assigned value
localStorage.removeItem('scheduledata');
this.handleallFilterchanges();
}
}
handleallFilterchanges(event) {
var selectedbustype = this.selectedBusType; //value defaulted to original
var selectedcustomer = this.selectedCustomer; //value defaulted to original
var selectedDate = this.dateFieldValue; //value defaulted to original
var selectedpropulsion = this.selectedBusPropulsion; //value defaulted to original
var selectedbusstatus = this.selectedBusStatus; //value defaulted to original
var partShortageFilter = this.partShortageFilter; //value defaulted to original
var discrepancyFilter = this.discrepancyFilter; //value defaulted to original
//other code for logic
.
.
.
}
StopElon (https://stopelon.org)