PDA

View Full Version : Changing paging grid example to read Domino JSON view



kerocs
3 Sep 2009, 1:54 PM
Hi,

I'm trying to build an ext website where I can use grids filled with data from a Domino server view (7.0.2).
I started out from the example where a grid is filled by a Ext.data.ScriptTagProxy. It needs to be a cross domain solution.

Can anyone try to help me out achieving this.
IE7 is trowing a error expecting ';' at line 3 char 19
Firefox is trowing an invalid label "@toplevelentries": 27\n
The grid is loading and stops after a while

Many thanks for your efforts. I tried everything being a newbie in understanding ext

The html page is at http://bcat.be/ext-3.0.0/ext-3.0.0/examples/BCATGRID/paging.html

Here's the paging.js
I remarked several tryout url's


/*!
* Ext JS Library 3.0.0
* Copyright(c) 2006-2009 Ext JS, LLC
* [email protected]
* http://www.extjs.com/license
*/
Ext.onReady(function(){

// create the Data Store
var store = new Ext.data.JsonStore({
//original root: 'topics',
root: 'viewentry',
//original totalProperty: 'totalCount',
totalProperty: '@toplevelentries',
//original idProperty: 'threadid',
idProperty: '@noteid',
remoteSort: true,

fields: [
'@name'
// 'title', 'forumtitle', 'forumid', 'author' ,
// {name: 'replycount', type: 'int'},
// {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
// 'lastposter', 'excerpt'
],

// load using script tags for cross domain, if the data in on the same domain as
// this page, an HttpProxy would be better
proxy: new Ext.data.ScriptTagProxy({
//original url: 'http://extjs.com/forum/topics-browse-remote.php'
url: 'http://kerocs.dynalias.com/websites/bcat/bcat.nsf/testjson?ReadViewEntries&outputformat=JSON'
//other server url: 'http://www.codestore.net/fakenames.nsf/($VIMPeople)?ReadViewEntries=1&StartKey=ree&UntilKey=ree_&count=10&OutputFormat=JSON'
//file on server url: 'http://kerocs.dynalias.com/paginggrid.json'
})
});
// store.setDefaultSort('lastpost', 'desc');


// pluggable renders
function renderTopic(value, p, record){
return String.format(
'<b><a href="http://extjs.com/forum/showthread.php?t={2}" target="_blank">{0}</a></b><a href="http://extjs.com/forum/forumdisplay.php?f={3}" target="_blank">{1} Forum</a>',
value, record.data.forumtitle, record.id, record.data.forumid);
}
function renderLast(value, p, r){
return String.format('{0}<br/>by {1}', value.dateFormat('M j, Y, g:i a'), r.data['lastposter']);
}

var grid = new Ext.grid.GridPanel({
width:700,
height:500,
title:'ExtJS.com - Browse Forums',
store: store,
trackMouseOver:false,
disableSelection:true,
loadMask: true,

// grid columns
columns:[{
id: 'topic', // id assigned so we can apply custom css (e.g. .x-grid-col-topic b { color:#333 })
header: "Topic",
dataIndex: 'Naam',
width: 420,
// renderer: renderTopic,
sortable: true
// },{
// header: "Author",
// dataIndex: 'author',
// width: 100,
// hidden: true,
// sortable: true
// },{
// header: "Replies",
// dataIndex: 'replycount',
// width: 70,
// align: 'right',
// sortable: true
// },{
// id: 'last',
// header: "Last Post",
// dataIndex: 'lastpost',
// width: 150,
// renderer: renderLast,
// sortable: true
}],

// customize view config
viewConfig: {
forceFit:true,
enableRowBody:true,
showPreview:true,
getRowClass : function(record, rowIndex, p, store){
if(this.showPreview){
p.body = '<p>'+record.data.excerpt+'</p>';
return 'x-grid3-row-expanded';
}
return 'x-grid3-row-collapsed';
}
},

// paging bar on the bottom
bbar: new Ext.PagingToolbar({
pageSize: 25,
store: store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display",
items:[
'-', {
pressed: true,
enableToggle:true,
text: 'Show Preview',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed){
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
}]
})
});

// render it
grid.render('topic-grid');

// trigger the data store load
store.load({params:{start:0, limit:25}});
});

Bob Wilson
10 May 2012, 12:21 AM
Hi,

I'm also interested in such a feature, but I'm still a newbie at Ext and don't know how to map Domino ReadViewEntries JSON and Ext store, because ReadViewEntries is giving a hierarchical structure whereas the Store fields seems to be flat formatting.

Would you have a working example of your "Domino JSON to Ext view" ? I'm really interested.
Thanks for your help.