Sharepoint:显示具有“兼容”功能的非 Sharepoint 内容列表的最佳方式 用户界面?
我为 Sharepoint 构建了一个 Web 部件,用于从外部服务检索数据。 我想以一种与 Sharepoint UI 兼容的方式显示项目(适合其周围环境)。
我知道“DataFormWebPart”,但无法使其正常工作。 它需要一个有效的数据源,而我无法根据 Web 服务调用的结果构建一个数据源...部分问题是我的 Web 服务包装器没有公开 XML 返回信息,而是我有一堆反序列化对象。 似乎没有一种简单的方法可以将实际对象转换为数据源,或从对象数据填充“通用”数据源。
我可以使用 SPGridView 来获得相同的 UI,但网格控件没有太多智能 - 而且 - 它强制每个字段进入其自己的列。 我更喜欢将每个列表项呈现为具有复杂渲染的单个单元格(例如 StackOverflow 显示其问题列表的方式)。我还希望获得尽可能多的 Sharepoint 标准 UI,例如排序、过滤和分页控件。
因此,首先:这里是否有人编写了执行此操作的 Sharepoint 控件?如果是,您是否有示例代码可以分享? 如果不是:我是否忽略了一些有用的控制,无论是 MS 提供的还是外部库中提供的?
谢谢! 史蒂夫
I've built a web part for Sharepoint that retrieves data from an external service. I'd like to display the items in a way that's UI-compatible with Sharepoint (fits in with its surroundings.)
I'm aware of the "DataFormWebPart" but was unable to get one working properly. It requires a valid DataSource and I was unable to build one from the results of a web service call... Part of the problem is that my web service wrappers don't expose the XML return info, rather I have a bunch of deserialized objects. There doesn't seem to be an easy way to turn actual objects into a datasource, or populate a "generic" datasource from object data.
I could use an SPGridView to get the same UI, but the grid control doesn't have much in the way of smarts -and- it forces every field into its own column. I'd prefer to render each list item as a single cell with complex rendering (for instance the way that StackOverflow shows its lists of questions.) I'd also like to get as much of the Sharepoint-standard UI as possible, such as the sorting, filtering, and paging controls.
So, first: Has anyone here written a Sharepoint control that does this, and if so do you have sample code to share? If not: am I overlooking some useful control, whether MS-supplied or available in an external library?
Thanks!
Steve
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在我看来,执行此操作的最佳方法是制作一个 Web 部件。 作为 Web 部件,UI 将自动呈现为与网站正在使用的主题相同(除非您覆盖它),并且具有管理员权限的任何人都可以将其放置在任何位置。
The best way to do this IMO is to make a Web Part. As a Web Part the UI will be automatically rendered to be the same as the theme the site is using (unless you override it) and it will be able to be placed anywhere by anyone with admin privileges.
您可以创建自定义 Web 部件并使用 SPGridView。 你说你不喜欢它,因为它迫使每个领域都有自己的栏目,但事实并非如此。 您可以为每个列创建一个模板 (ITemplate),并完全自定义其中显示的内容,就像使用普通的 ASP.Net GridView 一样。 使用这种方法,我在列表项标题旁边添加了一些“新”小图像,就像 SharePoint 本身一样。
You could create a custom web part and use an SPGridView. You say you don't like it, because it forces every field into its own column, but that's not true. You can create a template (ITemplate) for every column and fully customize what's shown inside it, just like you would using a normal ASP.Net GridView. Using this approach I've added the little "New" images right next to a list item's Title, just like SharePoint does itself.
查看内置的 sharepoint Web 控件:
Microsoft.SharePoint .WebControls Namespace
它包含了sharepoint中使用的所有控件。 我会告诉你更多,但文档非常详尽。
Take a look at the built in sharepoint web controls:
Microsoft.SharePoint.WebControls Namespace
It contains all the controls used in sharepoint. I'd tell you more, but the documentation is very thorough.
SharePoint 的问题在于有很多不同的方法可以做到这一点。 如果您的数据变化不是太频繁,也不是太大,那么可能值得考虑将其输入列表中进行显示。
如果您拥有企业许可证,则可能值得将您的数据放入 BDC 并在那里使用。
您可能必须将对象转换为 xml 或将序列化对象与 XML Web 部件一起使用才能显示。 这仍然存在使用 XSLT 自定义呈现的问题。
Problem with SharePoint is that there are a bunch of different ways to do this. If your data is not changing too often and is not overly large it may be worth considering entering it into a list for display.
If you have the Enterprise licence it may be worth getting your data into the BDC and using it there.
you may have to convert the objects into xml or use the serialised objects with the XML webpart for display. This still has the issue of custom rendering using XSLT.
这里有一篇很棒的文章,介绍了如何使用 BDC 定义编辑器配置 BDC 与 Web 服务的连接:
使用业务数据目录定义编辑器创建 Web 服务连接
http://msdn.microsoft.com/en-us/library/bb737887。 ASPX
Here's a great article that explains how to configure BDC connections to web services using the BDC Definition Editor:
Creating a Web Service Connection by Using the Business Data Catalog Definition Editor
http://msdn.microsoft.com/en-us/library/bb737887.aspx