使用新 ID 重定向 Sharepoint 列表
我在 Sharepoint 中有一个列表,使用自定义新表单添加了自定义列表表单控件(列表的“新项目表单”),并将 SaveButton 更改为标准输入 HTML 按钮,并添加了一个“onclick”事件,即如下所示:
onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={NewFormWizard2.aspx?id=}')}"
这就像保存数据并重定向到 NewFormWizard2.aspx?id= 页面一样。
如何获取要传递到重定向页面的已创建项目的 ID?
因此,一旦表单完成,它将重定向到 NewFormWizard2.aspx?id=23
I have a list within Sharepoint, using a custom new form I have added a custom list form control ("New item form" for the list) and changed the SaveButton to a standard input HTML button, and added an 'onclick' event that is as follows:
onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={NewFormWizard2.aspx?id=}')}"
This works as in saves the data and redirects to the NewFormWizard2.aspx?id= page.
How do I get the ID of the created item to be passed to the redirected page?
Thus once the form is completed it would redirect to NewFormWizard2.aspx?id=23
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
jtherkel 很接近,但在重定向网址末尾缺少“}”。 我在下面使用了额外的 concat
jtherkel was close, but was missing a '}' on the end of the redirect url. I used an extra concat below
我不确定该 ID 将存在于您托管 Javascript 的页面上的哪个位置。 它出现在查询字符串中还是页面上的字段中?
请求或响应中没有任何内容可以识别该项目。 我在进行一些网络负载测试时遇到了这个问题。
我只能建议您使用网络服务创建该项目,因为它会为您提供一些返回 xml。
I am not sure where the ID will exist on the page you host the Javascript from. Does it appear in the querystring or on a field on the page?
There is nothing in the request or response that will identify the item. I have had this issue when doing some web loadtesting.
I can only suggest that your create the item using the webservices as that at gives you some return xml.
此答案并不能解决“新表单”问题,但它可能会帮助其他人了解包含现有列表项的屏幕的语法。
我在我的 SharePoint (MOSS 2007) 环境中对此进行了快速测试。
onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={NewFormWizard2.aspx?id=',/dsQueryResponse/Rows/Row/@ID))}"
concat 语法是告诉处理器的 XSLT 指令组合用单引号括起来的值。 我根据我在这里找到的信息改编了这个答案。
在自定义列表表单中加载值
http://wssdevelopment.blogspot.com/2007_04_01_archive.html
This answer does not solve the "new form" issue, but it might help others with the syntax for screens that contain existing list items.
I tested this quickly in my SharePoint (MOSS 2007) environment.
onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={NewFormWizard2.aspx?id=',/dsQueryResponse/Rows/Row/@ID))}"
The concat syntax is an XSLT instruction that tells the processor to combine the values enclosed in single quotes. I adapted this answer from info I found here.
Loading Values in a Custom List Form
http://wssdevelopment.blogspot.com/2007_04_01_archive.html
我希望这会有所帮助:
1- 在 SharePoint Designer 中创建新页面,将其命名为“LastItem.aspx”,并在其上放置一个数据视图,其中包含目标列表项的单个表单视图。
2-将分页限制为仅一条记录,设置按 ID 和降序排序,并过滤列表以仅显示 [当前用户] 创建的项目。
3-现在您不需要将任何查询字符串传递到此页面。 只需用标准 HTML 输入按钮替换列表 NewForm.aspx 中的默认“确定”按钮,并将其添加到其定义中“onclick=”javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={LastItem.aspx}) “。将新项目提交到列表后,您将被重定向到所创建项目的编辑视图。
您可以对 LastItem.aspx 中的保存按钮执行相同的操作,以在单击保存按钮后重定向到其他页面。
I hope this would be helpfull:
1- In SharePoint Designer create new page, call it for example "LastItem.aspx" and place a dataview on it with a single form view for the destination list item.
2-Limit paging to just one record, set the sorting by ID and descending and filter the list to just show item which is created by [current user].
3-Now you do not need to pass any query string to this page. just replace the default "OK" button in NewForm.aspx of the list with a standard HTML input button and add this to its definition "onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={LastItem.aspx}". After submitting a new item to list you will be redirected to an edit view of the created item.
You can do the same for save button in LastItem.aspx to redirect to some other page after clicking on save button.
找到了一种使用纯 javascript (JQuery) 和 http://darrenjohnstone.net/ 的 SPAPI 代码的方法。
该列表包含两个字段,标题和正文复制
我创建了一个表单,要求输入标题和问题,这两个字段都是文本字段,然后提交按钮调用以下函数:(请注意,ServerAddress 和 LIST_question 需要更新为您的自己的详细信息)。
然后,该函数使用 LISTS.ASMX 中的 SOAP 服务上传详细信息,并使用响应获取新项目的 ID 并重定向页面。
found an approach using pure javascript (JQuery) and the SPAPI code from http://darrenjohnstone.net/.
The list contains two fields, title and BodyCopy
I've thewn created a form that asks for a title and a question, both text fields, then the submit button calls the following function: (note that ServerAddress and LIST_question need to be updated to your own details).
The function then uploads the details using the SOAP service within LISTS.ASMX and using the response gets the ID of the new item and redirects the page.
您可以使用 JavaScript http://www.sharepointdrive 来实现此目的。 com/blog/Lists/Posts/Post.aspx?ID=9
You can achieve this using JavaScript http://www.sharepointdrive.com/blog/Lists/Posts/Post.aspx?ID=9