PDA

View Full Version : SHARE: Save --> Refresh document --> Update the view



Fredric Berling
5 Jun 2008, 6: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)
}

RWaters
5 Jun 2008, 9:47 AM
Looks pretty good. UIView provides a refresh function rather than grabbing the bottom toolbar and getting the store and refreshing.
So instead of this:


Print |var gridPanel = window.parent.ExtndApp.ui.tabPanel.findById('xnd-grid-panel');|
Print |var grid = gridPanel.items.items[0];|
Print |var bbar = grid.getBottomToolbar();|
Print |bbar.store.load(); |

You could do


Print |var view = window.parent.ExtndApp.ui.uiView;|
Print |view.refresh();|

Fredric Berling
6 Jun 2008, 11:24 PM
Ofcourse....Thanks alot.... Ill edit the post

mth96a
10 Jun 2008, 12:08 PM
any ideas?



DominoViewStore(Object count=40)extnd-all.js (line 28)
handleCategoryChange(undefined)extnd-all.js (line 78)
validate()89D6564B204AB1968... (line 104)
handler()extnd-all.js (line 145)
apply()ext-base.js (line 9)
initComponent(Object browserEvent=Event unload button=-1 type=unload)ext-all.js (line 87)
EventManager()ext-all.js (line 13)
getViewWidth()ext-base.js (line 10)
[Break on this error] Ext.nd.data.DominoViewStore=function(config){Ext.nd.data.DominoViewStore.supercl...

mth96a
10 Jun 2008, 12:51 PM
refresh({params:{options: ''}});

daddyschmack
9 Mar 2009, 7:04 AM
this code calculates the number of rows to display based on height of the window. It works for me, you may need to adjust the denominator (purple text) in the getRowCount Function.
the refresh view paramater call is in green!

snippet of code to calculate and refresh number of rows:


... getRowCount = function(){
body = Ext.getBody();
height =body.getHeight(true);
return Math.round(height/
24.75)
};
fixRowsCount = function(){
nCount = getRowCount();
pmStart.ui.uiView.refresh({params:{
count:nCount,
searchCount:nCount
}
});
function RowContextMenuMini(grid, rowIndex, e) {
e.stopEvent();
var menu = new Ext.menu.Menu({
id : 'xnd-context-menu'
});
menu.add({editMode : false, text : 'Open', handler : pmStart.ui.uiView.gridContextMenuOpenDocument, scope: this});
menu.add({editMode : true, text : 'Edit', handler : this.gridContextMenuOpenDocument, scope: this});
menu.addSeparator();
menu.add({text : 'Search This View', handler : this.gridContextMenuSearchView, scope: this});
// tell menu which row is selected and show menu
menu.grid = this.grid;
menu.rowIndex = rowIndex;
var coords = e.getXY();
menu.showAt([coords[0], coords[1]]);
};
var pmStart = function() {
return {
init : function(){
Ext.QuickTips.init();

this.ui = new Ext.nd.DominoUI({
uiOutline : {outlineName: "Main"},
uiView :
{viewName: "Manufacturer Info Look-up",
viewTitle: "Manufacturer Info Reference",
id: 'uiView',
autoscroll: true,
showPagingToolbar : true,
showActionbar : true,
showSearch : true ,
searchCount : getRowCount(),
count: getRowCount(),
searchInPagingToolbar: false,
gridConfig: {
viewConfig: {
forceFit: true
},
listeners:{'resize' : function(){fixRowsCount()}}, // refresh number of rows called from here
layout: 'fit',
trackMouseOver:true,
stripeRows : true,
frame : true,
autoWidth: true,
height: '97%'

}
}
});


this.ui.uiView.gridHandleRowContextMenu = RowContextMenuMini;
this.ui.outlinePanel.hide();
this.ui.viewport.doLayout();
this.ui.viewport.setSize({width: '100%', height: '98%'});
window.resizeBy(1,0)
/
}// end init

} // return

}();

Ext.onReady(pmStart.init, pmStart, true);