When you have a long List page with dozens of records, editing or viewing a record on a separate can be cumbersome. After you edit or view a record, clicking 'Back to List' will display all the records from the top and you lost the position of the record you just edited. This simple technique will allow you to scroll the List page back to the original position and also it will highlight the record that was just edited or viewed.
To implement this feature in your project, add the following code to respective events.
List page --> Javascript onload event
window.onscroll = function() { localStorage.setItem('scroll_value', window.pageYOffset); }; if(localStorage.getItem('scroll_value')){ window.scrollTo(0, localStorage.getItem('scroll_value')); localStorage.setItem('scroll_value', 0); } if(localStorage.getItem("editid1")){ var id = $("[href*='editid1="+localStorage.getItem("editid1")+"']:first").closest("tr").attr("id"); $("#"+id).css("background-color","#AFEEEE"); localStorage.setItem("editid1",""); }
Add page --> Javasctipt onload event
localStorage.setItem("editid1",proxy["editid1"]);
Add page --> After Record Added event
PHP:
$k = array_values($keys); $pageObject->setProxyValue("editid1", $k[0]); echo " ";
C#:
dynamic k = XVar.Array(); k = XVar.Clone(CommonFunctions.array_values((XVar)(keys))); pageObject.setProxyValue(new XVar("editid1"), (XVar)(k[0])); MVCFunctions.Echo(" ");
Edit page / View page --> Javascript onload event
localStorage.setItem("editid1",proxy["editid1"]);
Edit page / View page --> Bebore Display event
PHP:
$pageObject->setProxyValue("editid1",postvalue("editid1"));
C#:
pageObject.setProxyValue(new XVar("editid1"), (XVar)(MVCFunctions.postvalue(new XVar("editid1"))));
This is it. Enjoy!