在 SharePoint 2010 中,如何在运行时添加用户选择的 WebPart?

发布于 2024-12-07 15:57:44 字数 727 浏览 0 评论 0原文

我对 SharePoint 还很陌生,并且遇到了一个有趣的问题需要解决。我的用户要求每个人都有一个可以轻松定制的自定义主页。我得到的设计是有一个几乎空白的页面,其中有 4 个 Web 部件的空间,以 2 × 2 的方式组织(2 个 Web 部件 × 2 个 Web 部件),每个部件都有一个大的“+”按钮,可以单击以选择并添加小部件他们的选择,而不必摆弄丝带。预计看起来像这样:

http://imageshack.us/photo /my-images/841/homepages.jpg/

现在,当用户单击“+”时,将显示一个 SharePoint 对话框,允许用户从所有可用的 Web 部件中进行选择。选择其中一个后,主页将刷新,并且小部件将显示在所选区域中。

我目前正在尝试降低此请求的风险,看看是否可以在给定的时间内实现。我目前遇到的问题如下:

  1. 以编程方式获取要在对话框中显示的所有可用 Web 部件的列表。
  2. 在选择 Web 部件时,以编程方式将所选 Web 部件添加到主页的正确部分,而无需对 Web 部件的类型进行硬编码(因此,当将新 Web 部件添加到 SharePoint 供用户添加时,不需要更改代码)。

我非常感谢对此的任何帮助或建议。提前致谢,如果问题措辞得当,抱歉,这是我的第一个 Stack Overflow 问题!

I am quite new to SharePoint and have been given an interesting problem to solve. My users have requested to each have a custom home page that they can customise with ease. The design I have been given is to have an almost blank page with space for 4 webparts organised in a 2 by 2 fashion (2 webparts by 2 webparts) each with a big '+' button in witch to click to select and add a widget of their choosing without having to play around with the ribbon. This is expected to look something like this:

http://imageshack.us/photo/my-images/841/homepages.jpg/

Now when a user clicks a '+' a SharePoint dialog is to be displayed allowing the user to choose from all available web parts. On selecting one the home page is refreshed and the widget is displayed in the selected zone.

I am currently trying to de-risk this request to see if it is possible to achieve in the time frame given. The problems I have at the moment are as follows:

  1. Programmatically getting a list of all available webparts to display in the dialog.
  2. On the selection of the webpart programmatically adding that chosen webpart to the correct part of the home page without hard coding the type of webpart (so the code does not need to be changed when a new webpart is added to SharePoint for users to add).

I would really appreciate any help or advice on this. Thanks in advance and sorry if the question is well phrased, this is my first Stack Overflow question!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2024-12-14 15:57:44

只需创建一个可以执行此操作的 Web 部件即可。
呈现一个大加号,当用户单击此处时,事件处理程序会获取所有可用的 Web 部件并将其呈现到下拉列表等。其余的很简单,当用户选择一个时,获取它(通过 guid/名称等)并将其添加到第一个 Web 部件所在的区域,不要忘记从该区域中删除加号 Web 部件首先点击webpart zone
这可以使用 SPLimitedWebPartManager 来实现。

棘手的部分可能是 SiteCollection 上可用的 Web 部件,但您可以对此进行研究。

问候,

佩德罗

Just create a webpart that does that.
Render a big plus sign and when a user clicks there, the event handler gets all webparts available and renders it to a dropdownlist for instance. The rest is easy, when a user selects one, get it (by guid/name whatever) and add it to the zone where the first webpart was present, not forgetting to remove the plus sign webpart from the clicked webpart zone first.
This can be achieved using the SPLimitedWebPartManager.

The tricky part could be the Webparts that are available on the SiteCollection, but you could research on that.

Regards,

Pedro

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文