Zen Page Table From another namespace

Hello,

Need some technique to solve an issue about zen page table.

- "xyz" table exists in all my namespaces.

I have a simple Zen page  in "USER 1" namespace. It has a tablepane which pulls data from "xyz" table.

OnLoad of the page i want the  zenpage to pull the data from "USER 2" namespace with same "xyz" table name.

 

Zenpage has to be in  "USER 1" namespace

 

I tried to use the server side callback handler %OnAfterCreatePage()  and do a ZNSPACE "USER 2" but still it is not doing the job of pulling data from another namespace.

 

Any suggestions will be appreciated.

Thanks,

Jimmy Christian.

  • 0
  • 1
  • 74
  • 8
  • 2

Answers

For example so:

Class dc.test Extends %ZEN.Component.page
{

XData Style
{
<style type="text/css">
</style>
}

XData Contents [ XMLNamespace "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
  <tablePane
    OnCreateResultSet="CreateRS"
    OnExecuteResultSet="ExecuteRS"
  >
    <parameter name="ns" value="USER1"/>
  </tablePane>
  <tablePane
    OnCreateResultSet="CreateRS"
    OnExecuteResultSet="ExecuteRS"
  >
    <parameter name="ns" value="USER2"/>
  </tablePane>
</page>
}

Method ExecuteRS(
  myRS As %ResultSet,
  Output pSC As %Status,
  pInfo As %ZEN.Auxiliary.QueryInfoAs %Boolean
{
  myRS.Prepare("select * from xyz")
  myRS.Execute()
  tSC=$$$OK
  q $$$YES
}

Method CreateRS(
  Output tSC As %Status,
  pInfo As %ZEN.Auxiliary.QueryInfoAs %ResultSet
{
  rs=##class(%RemoteResultSet).%New()
  rs.UserName="_system"
  rs.Password="SYS"
  rs.ConnectionString=$$$FormatText("localhost[%1]:%2",##class(%SQL.Manager.API).GetPort(),pInfo.parms(1))
  tSC=$$$OK
  q rs
}

}

Hello Vitaliy,

Thank you for your time. This works good. Issue is that i only see the first page of the results.

Even after adding the tableNavigatorBar, it still shows only one page  and not all the results. I have more than 30,000 rows to display on the page. Let me know.

Thanks,

Jimmy

Try this:

XData Contents [ XMLNamespace "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen">
  <tableNavigatorBar tablePaneId="tp1"/>
    <tablePane
      id="tp1"
      OnCreateResultSet="CreateRS"
      OnExecuteResultSet="ExecuteRS"
      maxRows="0"
      pageSize="10"
      useSnapshot="true"
    >
    <parameter value="USER1"/>
  </tablePane>
  <tableNavigatorBar tablePaneId="tp2"/>
    <tablePane
      id="tp2"
      OnCreateResultSet="CreateRS"
      OnExecuteResultSet="ExecuteRS"
      maxRows="0"
      pageSize="10"
      useSnapshot="true"
    >
    <parameter value="USER2"/>
  </tablePane>
</page>
}

Vitaliy, This is great !

The code works fine now. Appreciate your help and time.

I have to put some filters on the columns now, which i think i have to use the QueryInfo Object.

Thank you !

Regards,

Jimmy Christian.

Share globals and packages across Namespaces. Thats the only way

 

Thanks Neerav.

I still believe  we can do in the code by using a callback method. I am not sure how to use it.

Callbacks are for Stored Procedures which are a part of Database.

What I would suggest is make a minimal view in your namespace 2 and just share that with Namespace1 , if that works for you

Thanks Neerav.

I am referring to the zenpage call back methods, which are called on a zenpage event.

Problem is i cannot create any views in namespace2.

I cannot share globals on the namepsace i am working on.

Actually i was able to retrieve data from Namespace2  working on a callback method for recordset which the table  is using. But now issue is zenpage only shows the first page.

Will try to find out a reason why the page is hanging. It could be that i have to flip back to Namespace1 once i get the recordset.

Thanks.

Zen stores data in snapshots for pagination. May be its not able to do so by a callback method.