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:

ClientMethod Test1button() [ Language = javascript ]
{
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!

  • 0
  • 0
  • 89
  • 1
  • 2

Answers

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 

table.refreshContents();

3. Add one new method:

/// This client event, if present, is fired when the page is loaded.
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:

ClassMethod GetPage() As %String [ ZenMethod ]
{
 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

at first sight, I miss in this  piece  of code

ClassMethod GetPage() As %String) [ ZenMethod ]
{ quit 
%session.Data("currPage") }

and

var pageNo zenPage.GetPage() ;

Comments

Great! Thank you Vladimir and Robert, I have got it working!