mercredi 31 décembre 2014

List View Web part not showing all available views for list



We have added a list view web part to a page, and we get the Current View link in the web part. Which is configurable when modifying the actual web part.


What we'd like to see (instead of having to click the ellipses button/context menu to get the other views) is the views displayed horizontally like when you are viewing the list itself.


When viewing the list itself, we see All Items View 1 View 2, etc.


Is this possible in the list view web part to display all available views in a horizontal/breadcrumb layout? Please advise.


Trying this in simple webpart code snippet, but not responding:



<script>
function showMeViewsJS(){

var viewCollection = null;
function runCode() {

var clientContext = new SP.ClientContext.get_current();
if (clientContext != undefined && clientContext != null) {
var web = clientContext.get_web();

var listCollection = web.get_lists();
var list = listCollection.getByTitle("Students");
this.viewCollection = list.get_views();

var viewInfo = new SP.ViewCreationInformation();
viewInfo.set_title('MyView');
this.viewCollection.add(viewInfo);

clientContext.load(this.viewCollection);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
}

function onQuerySucceeded() {
var viewInfo = 'Tasks list current views: \n\n';
var viewEnumerator = this.viewCollection.getEnumerator();
while (viewEnumerator.moveNext()) {
var view = viewEnumerator.get_current();
viewInfo += view.get_title() + '\n';
}
alert(viewInfo);
}

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

}
</script>
<a onclick='return showMeViewsJS();'>Click here</a>







0 commentaires:

Enregistrer un commentaire