Storing currPage in %session.data
HI Community,
I would like to store a tablepane currPage variable in %session.Data, and retrieve the value when returning from a detail page back to the tablepane.
My test code so far:
{
var table = this.getComponentById('relationTable');
var pageNo = table.getProperty('currPage');
alert (pageNo)
zenPage.SetPage(pageNo)
}
ClassMethod SetPage(pageNo As %String) [ ZenMethod ]
{
Set %session.Data("currPage") = pageNo
//&js<alert(pageNo);>
}
ClientMethod Test2button() [ Language = javascript ]
{
var pageNo = ""
zenPage.GetPage(pageNo)
///alert (pageNo)
var table = this.getComponentById('relationTable');
table.setProperty('currPage',pageNo)
table.refresh
However the code does not work,
Suggestions appreciated, Thanks!
at first sight, I miss in this piece of code
ClassMethod GetPage() As %String) [ ZenMethod ]
{ quit %session.Data("currPage") }
and
var pageNo = zenPage.GetPage() ;
1. You omit semicolons - in javaScript every statement should finish with ";"
2. table.refresh will not work - it needs - (); in the end ,but in this case you
should use
3. Add one new method:
ClientMethod onloadHandler() [ Language = javascript ]
{
var pageNomer=1;
var pageNo=zenPage.GetPage();
var table = this.getComponentById('relationTable');
table.setProperty('currPage',pageNo);
table.refreshContents();
}
And your GetPage() method will be:
{
If $d(%session.Data("currPage")){quit %session.Data("currPage")}
else {quit 1}
}
Quit 1 is used when you start the page for the first time and
%session.Data("currPage")) is not set yet
Great! Thank you Vladimir and Robert, I have got it working!