1

In my page I'm using lightning-vertical-navigation. With Static and Dynamic Values. Each page has two Button next and previous

On-click of Next it should go to next navigation page. Click of previous button it goes to previous navigation Page.

For Example:

 School
 Class
 Student
    Student1
    Student2
    Student3
 Finish

Student1 Student2 Student3 are the dynamic values.

Static Navigation Code below

    handleOnNextPage() {     
        if (this.selectedItems === "school") {
          this.selectedItem = "class";
          return;
        }

        if (this.selectedItems === "class") {
          this.selectedItem = "student";
          return;
        }

        if (this.selectedItems === "student") {

        // it should goes to first sudent

          return;
        }
      }

We can Navigate from School to Class and Class to Student by using navigation Name Since it is static value.

My Question here is How we can navigate from Student to Student1 and Student1 to Student2 so on. Since it's a dynamic value.

Note: We have a option to add the new students in Student tab. Dynamically the value will be displayed under Students as Student{Name}

My thought process is we can add the value in the array and loop. not sure about this approach. can anyone Please help me how to proceed with this.

2

You've basically already answered this. Just create an array and use that to navigate around.

next() {
  this.selectedItems = this.tabs[this.tabs.indexOf(this.selectedItems)+1];
}
prev() {
  this.selectedItems = this.tabs[this.tabs.indexOf(this.selectedItems)-1];
}

This answer presumes that tabs are the names of the tabs in order:

tabs = ['school','class','student','student1','finish'];
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.