开发者

get currently selected list in javascript on load - sharepoint 2010

开发者 https://www.devze.com 2023-03-14 19:19 出处:网络
I\'m currently trying to find out, how to get a reference to currently selected list in sharepoint from javascript. I can get it if I know the title, or id, but I want it to get the list dynamically d

I'm currently trying to find out, how to get a reference to currently selected list in sharepoint from javascript. I can get it if I know the title, or id, but I want it to get the list dynamically depending on where the user is. I have this code (in my modal dialog):

ExecuteOrDelayUntilScriptLoaded(init, 'sp.js');

function init() {
    var context = SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getById(SP.ListOperation.Selection.getSelectedList());
}

The problem is that SP.ListOperation.Selection.getSe开发者_如何学JAVAlectedList() returns null. There is probably some other script I need to wait for - but which one?


I figured it out. SP.ListOperation.Selection.getSelectedList() doesn't work inside of a modal dialog. I needed to pass list ID from the parent window.


You may have found a bug in SharePoint web services (not that that's particularly surprising, given the sparseness of their API).

See here. I didn't look too carefully but BananaRepublic seemed to have a workaround for this problem; I don't know the exact context, so I don't know if it will work for you or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号