This topic is locked

Preserving Tab State after Save

8/8/2017 1:31:15 PM
ASPRunner.NET Tips and tricks
MK Frank R author

Greetings,
I am using ASPRunner.NET Enterprise V9.8. [The best RAD tool on the planet.]
We are building an app using the Bootstrap layout. We have an Edit page separated into sections with various Tabs. Turns out that if you are on, say, the third tab and click Save, it resets to the first tab. Here is a snippet to preserve Tab state across the Saves:
In List page Javascript OnLoad:



//---------------------------------------------------------------------

// From List page, establish that we would start at first Tab

//---------------------------------------------------------------------

localStorage.setItem('CurrentTab', 0);


In Edit page Javascript OnLoad:



//---------------------------------------------------------------------

// Before Save, this event fires to store what Tab user is actually on

//---------------------------------------------------------------------

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){

localStorage.setItem('CurrentTab', pageObj.getTabs().activeIdx());

});
//---------------------------------------------------------------------

// Set Tab based on what we have stored as Current Tab

//---------------------------------------------------------------------

pageObj.getTabs().activate(localStorage.getItem('CurrentTab'));
jadachDevClub member 8/8/2017

That is awesome. Thanks for sharing. And yes - best rad tool ever!

MK Frank R author 8/9/2017

Sergey and I tag teamed on that one. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=82867&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thank God there was a way. I really needed to preserve the current tab after a Save.