Hi Xenia,
I dont believe you'll be able to have that webpart display all those lists. For this, your best bet is probably just to use a wiki or HTML page which displays a similar list. It's not ideal, but fortunately the list webpart isnt very complex. |
Thanks, Ben - then how can I display those lists in, say, a Wiki? I would prefer to have the workflow somewhat similar to Lists webpart - when you LIST available lists, and the user then clicks on the list to see its contents. I do not need the user to see list design etc. |
Hi Xenia,
Below is a basic example that creates a panel with one row per list, displaying lists from multiple containers. The appearance of the panel could be modified pretty easily, and I hope this can provide a template to create your webpart. Let me know if you have any questions.
<script type="text/javascript">
Ext.onReady(function(){
var allLists = [];
var multi = new LABKEY.MultiRequest();
var config = {
schemaName: 'lists',
includeUserQueries: false,
success: function(result){
if(result.queries.length)
allLists = allLists.concat(result.queries);
},
error: function(response){
console.log('There was an error');
console.log(response);
}
};
//identify the parent path using URL. this isnt fool-proof, since the current user might not have read permission in that container.
// would also hard-code this path in your code, depending on your usage.
var containerArray = LABKEY.ActionURL.getContainer().split('/');
var parentPath = containerArray.slice(0, containerArray.length -1).join('/') || '/'; //default to root
//add one AJAX request per container. the config is otherwise shared between then. also make sure we dont modify the original config object
var containers = [LABKEY.ActionURL.getContainer(), parentPath]
Ext.each(containers, function(c){
multi.add(LABKEY.Query.getQueries, Ext.apply({containerPath: c}, config));
}, this);
//send multi-request, so we have since a callback when both are complete
multi.send(function(){
allLists = allLists.sort(function(a, b){return a.name > b.name ? 1 : (a.name < b.name ? -1 : 0);});
//aesthetics could probably be improved on this panel
//you could also choose to group these lists by container, rather than mingle them as this example does
var config = {
xtype: 'panel',
title: 'Lists', //remove title and set border=false to hide the outer part of this panel and make it look more like the normal list webpart
border: true,
bodyStyle: 'padding: 5px;',
defaults: {
border: false
},
items: []
};
Ext.each(allLists, function(list){
config.items.push({
html: '<a href="' + list.viewDataUrl + '">' + list.name + '</a>'
})
}, this);
new Ext.Panel(config).render('listDiv');
}, this);
});
</script>
<div id="listDiv"></div> |