在 SharePoint 中使用 XPath 检索控件/选择值
表单是从列表中填充的,我需要对其进行过滤。我有一个带有日期列的表,并且想仅显示所需月份的行。为此,我使用了 XPath 过滤:
[((ddwrt:FormatDateTime(string(@MyDateColumn) ,1061 ,'MM'))=02)]
这给了我二月份的结果,一切正常。现在我想要实现的是通过下拉列表选择月份:
<asp:DropDownList runat="server" id="DropDownList1">
<asp:ListItem Selected="True" Value="01">January
</asp:ListItem>
<asp:ListItem Value="02">February</asp:ListItem>
</asp:DropDownList>
如果有帮助的话,下拉列表也可以是常规的 html 选择,没有区别。但是如何使用 XPath 检索 select 的选定值?
尝试使用 XPath 来实现此目的,因为 SharePoint 的“常规”过滤仅允许按完整日期进行过滤,而不能单独按日、月或年进行过滤。
A form is populated from a list and I need it filtered. I have a table with a date column and would like to display only the rows of the required month. For this I have used XPath filtering:
[((ddwrt:FormatDateTime(string(@MyDateColumn) ,1061 ,'MM'))=02)]
This gives me the results for February, all ok. Now what I am trying to achieve is to make the month selectable with a drop-down list:
<asp:DropDownList runat="server" id="DropDownList1">
<asp:ListItem Selected="True" Value="01">January
</asp:ListItem>
<asp:ListItem Value="02">February</asp:ListItem>
</asp:DropDownList>
The drop-down can also be a regular html select if it would help, no difference there. But how can I retrieve the chosen value of the select with XPath?
Trying to achieve this with XPath because SharePoint's "regular" filtering only allows filtering by full date, not by day, month or year separately.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您有此 XML 文档(问题中的 ASP 文本不是格式良好的 XML):
并选择
$m
,则此 XPath 表达式:选择与
$m
对应的所需文本节点。上面的 XPath 表达式如下:
选择作为
value
属性等于$m
的值的任何元素的子元素的所有文本节点,并且该元素是文档的顶部元素。例如:
选择文本节点
“July”
例如
:
选择
value
属性,等于7
。If you have this XML document (the ASP text in the question isn't well-formed XML):
and selection
$m
, then this XPath expression:selects the wanted text-node that corresponds to
$m
.The XPath expression above reads:
Select all text nodes that are children of any element whose
value
attribute is equal to the value of$m
and that is a child of the top element of the document.For example:
selects the text node
"July"
and
for example:
selects the
value
attribute, equal to7
.啊太棒了,我的长答案和连接错误!这次更短:
我只想按月过滤表单/表格行。为此,我创建了一个 ASP.NET 控件 DropDownList:
现在,为了按日期列过滤我的 DataFormWebPart,我首先创建了一个参数。当为表单选择“过滤器”并在“值”列下选择“创建新参数...”时,可以轻松创建参数。刚刚从 Controls:DropDownList1 创建了一个参数 MyParameter。现在这个参数可以用在XPath过滤中:
Ah great, my long answer and connection error! Being shorter this time:
I just wanted to filter form/table rows by month. For this I created an ASP.NET Control DropDownList:
Now to filter my DataFormWebPart by the date column, I first created a parameter. A parameter can be easily created when choosing Filter for the form and under the Value column choosing Create new parameter.... Just created a parameter MyParameter from Controls:DropDownList1. Now this parameter can be used in XPath filtering: