SharePoint 在页面上显示带有多个 Web 部件的功能区
我创建了一个共享点页面,其中包含一个 xslt Web 部件和一个与问题无关的第二个 Web 部件,
当我们添加第二个 Web 部件时,功能区栏被隐藏,您必须单击该 Web 部件才能再次显示功能区栏。 我们无法要求用户单击 Web 部件,因此我尝试在 xslt 列表视图 Web 部件的上下文中使功能区栏始终可见。
在搜索此问题时,我发现当您在 SharePoint 源代码中使用反射器搜索此隐藏功能区行为时,这似乎是 Microsoft 设计的行为,如下例所示:
public override bool Visible {
get {
if (!this.SingleWebPartPresentOnPage)
return false;
else
return base.Visible;
}
}
有人遇到相同问题但没有解决方案:http://www.glynblogs.com/2011/02/list-view-selector-missing-with-multiple-web-parts-in-sharepoint-2010.html
可能吗强制功能区栏通过服务器端代码可见,或者我可以调用当我单击 Web 部件以显示功能区栏时正在使用的 javascript 代码吗?
我认为使用 javascript 应该可以,因为如果您单击 xslt web 部件,功能区是可见的,但我无法重现正在执行的代码。
I've created a sharepoint page that has an xslt webpart and a 2nd webpart that is unrelated to the question
When we add this second webpart the ribbon bar is hidden and you have to click the webpart to get the ribbon bar shown again.
Clicking the webpart isn’t something we can ask from our users so I’m trying to get the ribbon bar visible at all times with the context of our xslt listview webpart.
When searching for this problem I found out that when you search for this hidden ribbon behavior with reflector in the SharePoint source code it seems this is behavior that is designed by Microsoft as the example below shows:
public override bool Visible {
get {
if (!this.SingleWebPartPresentOnPage)
return false;
else
return base.Visible;
}
}
Someone with same problem but no solution: http://www.glynblogs.com/2011/02/list-view-selector-missing-with-multiple-web-parts-in-sharepoint-2010.html
Is it possible to force the ribbon bar to visible with server side code or can I call the javascript code that is being used when I click the webpart to show the ribbon bar?
I think it should be possible with javascript because if you click the xslt webpart the ribbon is visible but i can't reproduce the code thats being executed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用 JavaScript 重新选择 XSLTListViewWebPart,功能区将再次出现。
you can use JavaScript to reselect the XSLTListViewWebPart, that the ribbon appears again.
下面的Javascript对我有用!
在上面的脚本中,MSOZoneCell_WebPartWPQ4 是我的列表视图 Web 部件
Below Javascript worked for me!!
In the above script the MSOZoneCell_WebPartWPQ4 being my list view web part
一个很好的解决方案是获取视图页面上主 Web 部件的 contextualInfo。
A great solution is to grab the contextualInfo for the main webpart on your view page.
下面的版本使用 SharePoint 的按需脚本而不是 100 毫秒超时或 jquery。我认为这更可靠,因为它是在功能区初始化后准确执行的。
Below a version using SharePoint's Script On Demand instead of 100ms timeout or jquery. I think thats more solid, cuz it is exactly executed after the ribbon is initialized.
与 Thorstens 解决方案类似,我使用 jQuery 在 mouseenter 事件上触发 WpClick 函数。这种方法还解决了当用户第一次进入页面并尝试使用其中一个菜单时完整工具栏崩溃的问题。如果需要,您可以捕获页面上任意数量的 Web 部件的事件气泡。例如:
其中“body”可以是您想要的任何父元素,其中包含悬停时要自动选择的 Web 部件。
当仅关注一个 Web 部件时,或者为了在大页面上获得最佳性能,您还可以直接在区域上设置事件。
或者如果 jQuery 不可用
(可选),您仍然可以通过手动触发事件来强制功能区在页面加载之后和用户悬停之前显示。只需在附加上述事件后包含适当的代码即可。例如使用 jQuery
Similar to Thorstens solution, I use jQuery to fire the WpClick function on the mouseenter event. This approach also handles the issue where the Full Toolbar freaks out when a user first enters a page and tries to use one of the menus. You can trap the event bubble for any number of web parts on the page if desired. For example:
Where "body" could be any parent element you want that contains the web parts to auto select when hovering.
When only one web part is of concern, or for optimal performance on large pages you could also set the event directly on the zone.
or if jQuery is not available
Optionally, you can still force the Ribbon to appear after the page loads and before a user hovers by triggering the event manually. Just include the appropriate code after attaching the event above. e.g. using jQuery