迭代 SPListItem/SPList
我正在为人们在我们公司网站上执行任务制定一个清单。 我现在正在开发的功能是,一旦他们完成任务并将其标记为已完成,我希望我们的共享点 Web 部件向他们发送一封电子邮件,其中包含他们仍需要完成的内容的列表。
由于权力者希望能够随意在列表中添加和删除项目,因此它需要模块化,因此检查列表也需要模块化并以模块化术语编写。
我遇到的问题是所有任务都存储在现有代码的 SPList 中。 我不太确定如何遍历列表来查明该人是否已经完成了以下任务。我没有看到任何下一个、上一个、头部或尾部操作(正如我从列表中期望的那样)。由于索引使用字符串,因此它的行为更像是关联数据结构(映射)或数据库中的主键。
请帮忙并谢谢大家!
干杯,
-Jeremiah Tantongco
I'm making a checklist for people to do tasks on our company website.
The feature I'm working on right now is that once they complete a task and mark it as done, I want our sharepoint webpart to send an email to them containing a list of what they still need to finish.
Since the powers that be want to be able to add and subtract items to the list at will, it needs to be modular, therefore checking the list needs to be modular and written in modular terms as well.
The problem that I have is that all the tasks are stored in a SPList on the existing code.
I'm not exactly sure how to iterate over the list to find out whether that person has the done the following task already. I'm not seeing any next, previous, head or tail operations (as I would expect from a list). Since indexing uses a string, it behaves more like an associative data structure (map) or primary key from a DB.
Help please and thanks everyone!
Cheers,
-Jeremiah Tantongco
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SharePoint 列表不是计算机科学方式中的列表,而是最终用户期望的列表:事物的列表。
您应该更多地将列表视为类似于数据库表。如果您想根据条件查找表(List)中的记录(Items),那么您应该使用查询。
因此,在 SPList 中查找 SPListItems 的正确方法是使用 SPQuery,在其中以良好的 XML 语法 (CAML) 指定条件,然后将 SPQuery 传递给 SPList.GetItems,从而获取 SPListItems 的集合。
这应该会给你一些谷歌搜索的术语。如果您需要有关查询语法的更多帮助,请使用 U2U Caml 查询生成器或者给我们一些更具体的信息。
A SharePoint list is not a list in the Computer Science way, but is what an End-User would expect a list to be: a listing of things
You should more look at a list as being similar to a database table. If you want to find records (Items) in a table (List) based on conditions then you should use a query.
So the right way to find SPListItems in a SPList is to use an SPQuery where you specify your criteria in a nice XML syntax (CAML), then pass the SPQuery to SPList.GetItems and thereby get a collection of SPListItems back.
This should give you some terms to google for. If you need more help with the syntax of the query then use U2U Caml Query Builder or give us some more specific infomations.
是否应该遍历列表可能是一个有争议的问题,但如果不可避免(就像我的情况一样),可以使用以下代码。
Whether you should iterate through the list or not may be a matter of debate, but if it's unavoidable (as it was in my case) the following code can be used.
这可能会解决你的问题
This may solve your problem