I’m trying to append and remove ZEN components programmelly, following is
my test code:
Method ClearControlAuto reports “tableNavigator: Unable to find pageNo
control”, but ClearControl works well.
What’s wrong in method ClearControlAuto?
BTW, it’s Cache for Windows (x86-32) 2008.2 DS (Build 615U).
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="">
<button caption="append" onclick="zenPage.AppendControl();"/>
<button caption="clear" onclick="zenPage.ClearControl();"/>
<button caption="clearAuto" onclick="zenPage.ClearControlAuto();"/>
<pane id="test"/>
</page>
}
Method ClearControl() As %String [ ZenMethod ]
{
Set tHolder = %page.%GetComponentById("test")
Set tTab= %page.%GetComponentById("mytable")
Do tHolder.%RemoveChild(tTab)
Set tnav= %page.%GetComponentById("tablenav")
Do tHolder.%RemoveChild(tnav)
Quit ""
}
Method ClearControlAuto() As %String [ ZenMethod ]
{
Set tHolder = %page.%GetComponentById("test")
for i=0:1:tHolder.children.Count()
{
Set tComp = tHolder.children.GetAt(i)
If $IsObject(tComp)
{
Do tHolder.%RemoveChild(tComp)
}
Set tComp=""
}
Set tHolder = ""
Quit ""
}
Method AppendControl() As %String [ ZenMethod ]
{ Set tHolder = %page.%GetComponentById("test")
Set tOTName = "mytable"
Set tComp = ##class(%ZEN.Component.tablePane).%New()
Set tComp.useSnapshot=1
Set tComp.initialExecute =1
Set tComp.pageSize=10
Set tComp.maxRows=10
Set tComp.sql="select sClass,sDescr from sqluser.test"
Set tComp.id = tOTName
Set tNavi = ##class(%ZEN.Component.tableNavigator).%New()
Set tNavi.tablePaneId = tOTName
Set tNavi.id="tablenav"
Do tHolder.%AddChild(tNavi)
Do tHolder.%AddChild(tComp)
Quit ""
}
Regards,
Peng Qiao
-----------------------------------------------------------------------------
Hi Giaopeng,
Here is how the Method ClearControlAuto can work:
Method ClearControlAuto() As %String [ ZenMethod ]
{
Set tHolder = %page.%GetComponentById("test")
for i=tHolder.children.Count() :-1:4
{
Set tComp = tHolder.children.GetAt(i)
If $IsObject(tComp){Do tHolder.%RemoveChild(tComp)}
}
Quit ""
}
And make changes here:
XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ]
{
<page xmlns="http://www.intersystems.com/zen" title="">
<pane id="test">
<button caption="append" onclick="zenPage.AppendControl();"/>
<button caption="clear" onclick="zenPage.ClearControl();"/>
<button caption="clearAuto" onclick="zenPage.ClearControlAuto();"/>
</pane>
</page>
}
Vladimir
<트랙백 주소:http://groups.google.com/group/InterSystems-ZEN/browse_thread/thread/edca4cb2e137aeee#> |