Fredric Berling
06-05-2008, 09:42 AM
Now i think i have a pretty stable way of saving documents and refreshing both panel and the view.
I use a link in a outline to create new documents calling a function called "ShowDocumentInPanel" where i set the panel id to "newdoc" and title to "New Document" (or something like that)
After saving its pretty nifty to change the panel id so that users can create a new document without ending up in the same panel as before. So i have to change the id on the panel and the Title should ofcourse be the documents name after first save.
Most code is ripped from different post, so i dont take credit for anything!:D
This is my ShowDocumentInPanel function
function ShowDocumentInPanel(href, unid, title){
var entry = parent.ExtndApp.ui.tabPanel.getItem('pnl-'+unid);
var panelId = 'pnl-' + unid;
if(!entry){
var iframe = parent.Ext.DomHelper.append(document.body, {
tag: 'iframe',
frameBorder: 0,
src: href,
id: unid,
style: {width: '100%', height: '100%'}
});
parent.ExtndApp.ui.tabPanel.add({
id: panelId,
contentEl: iframe.id,
title: parent.Ext.util.Format.ellipsis(title,16),
layout: 'fit',
closable: true
}).show();
var panel = parent.Ext.getCmp(panelId);
var dom = parent.Ext.get(unid).dom;
var event = parent.Ext.isIE ? 'onreadystatechange' : 'onload';
dom[event] = (function() {
if (title != "") {
panel.setTitle(parent.Ext.util.Format.ellipsis(title,16));
} else {
panel.setTitle("Untitled");
}
}).createDelegate(dom);
} else {
entry.show();
}
}
In my WQS agent i print this:
Print |Content-Type:text/plain|
Print |Content-Type:text/html|
Print "<html>" + Chr(13) + Chr(10)
Print "<head>" + Chr(13) + Chr(10)
Print |<script>|
Print |var view = window.parent.ExtndApp.ui.uiView;|
Print |view.refresh();|
If DocObj.Note.fdPID(0)="newfile" Then
Print |window.top.RefreshDocumentInPanel('newfile','/|+DocObj.Note.thisdb(0)+|/0/|+DocObj.Note.fdDocumentKey(0)+|!Editdocument&PID=|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentDescription(0)+|')|
Else
Print |window.top.RefreshDocumentInPanel('|+DocObj.Note.fdDocumentKey(0)+|','/|+DocObj.Note.thisdb(0)+|/0/|+DocObj.Note.fdDocumentKey(0)+|!EditDocument&PID=|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentDescription(0)+|')|
End If
Print |</SCRIPT>|
Print "</head>" +Chr(13) + Chr(10)
Print "<body>" + Chr(13) + Chr(10)
Print "</html>" + Chr(13) + Chr(10)
NOTE !!As You see i store the panel id name in a field on the form (fdPID). This is done thrue the Query String to the Document
First part on the WQS agent part refreshes the current open view so that users can actually see what they just created ;)
The RefreshDocumentInPanel function is like this:
function RefreshDocumentInPanel(oldunid,href, unid, title){
ExtndApp.ui.tabPanel.remove('pnl-' + oldunid)
ShowDocumentInPanel(href, unid, title)
}
I use a link in a outline to create new documents calling a function called "ShowDocumentInPanel" where i set the panel id to "newdoc" and title to "New Document" (or something like that)
After saving its pretty nifty to change the panel id so that users can create a new document without ending up in the same panel as before. So i have to change the id on the panel and the Title should ofcourse be the documents name after first save.
Most code is ripped from different post, so i dont take credit for anything!:D
This is my ShowDocumentInPanel function
function ShowDocumentInPanel(href, unid, title){
var entry = parent.ExtndApp.ui.tabPanel.getItem('pnl-'+unid);
var panelId = 'pnl-' + unid;
if(!entry){
var iframe = parent.Ext.DomHelper.append(document.body, {
tag: 'iframe',
frameBorder: 0,
src: href,
id: unid,
style: {width: '100%', height: '100%'}
});
parent.ExtndApp.ui.tabPanel.add({
id: panelId,
contentEl: iframe.id,
title: parent.Ext.util.Format.ellipsis(title,16),
layout: 'fit',
closable: true
}).show();
var panel = parent.Ext.getCmp(panelId);
var dom = parent.Ext.get(unid).dom;
var event = parent.Ext.isIE ? 'onreadystatechange' : 'onload';
dom[event] = (function() {
if (title != "") {
panel.setTitle(parent.Ext.util.Format.ellipsis(title,16));
} else {
panel.setTitle("Untitled");
}
}).createDelegate(dom);
} else {
entry.show();
}
}
In my WQS agent i print this:
Print |Content-Type:text/plain|
Print |Content-Type:text/html|
Print "<html>" + Chr(13) + Chr(10)
Print "<head>" + Chr(13) + Chr(10)
Print |<script>|
Print |var view = window.parent.ExtndApp.ui.uiView;|
Print |view.refresh();|
If DocObj.Note.fdPID(0)="newfile" Then
Print |window.top.RefreshDocumentInPanel('newfile','/|+DocObj.Note.thisdb(0)+|/0/|+DocObj.Note.fdDocumentKey(0)+|!Editdocument&PID=|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentDescription(0)+|')|
Else
Print |window.top.RefreshDocumentInPanel('|+DocObj.Note.fdDocumentKey(0)+|','/|+DocObj.Note.thisdb(0)+|/0/|+DocObj.Note.fdDocumentKey(0)+|!EditDocument&PID=|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentKey(0)+|', '|+DocObj.Note.fdDocumentDescription(0)+|')|
End If
Print |</SCRIPT>|
Print "</head>" +Chr(13) + Chr(10)
Print "<body>" + Chr(13) + Chr(10)
Print "</html>" + Chr(13) + Chr(10)
NOTE !!As You see i store the panel id name in a field on the form (fdPID). This is done thrue the Query String to the Document
First part on the WQS agent part refreshes the current open view so that users can actually see what they just created ;)
The RefreshDocumentInPanel function is like this:
function RefreshDocumentInPanel(oldunid,href, unid, title){
ExtndApp.ui.tabPanel.remove('pnl-' + oldunid)
ShowDocumentInPanel(href, unid, title)
}