默认新子列表项为选定的父列表项

发布于 2024-10-17 04:23:31 字数 147 浏览 4 评论 0原文

我有一个名为“项目”的 Sharepoint 列表和另一个名为“任务”的列表。任务列表有一个项目列表标题的查找字段,以便我可以使用“插入相关列表”选项。插入相关列表后,选择一个项目将仅显示与该项目关联的任务。
添加新任务时,如何让任务列表将项目查找值默认为当前选定的项目?

I have a Sharepoint list called Projects and another list called Tasks. The Tasks list has a lookup field to the title of the projects list so that I can use the "Insert Related List" option. Once the related list is inserted, selecting a project will display only tasks associated with that project.
How can I have the Tasks list default the project lookup value to the currently selected project when a new task is added?

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

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

发布评论

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

评论(1

神经暖 2024-10-24 04:23:31

基于 Corey Martins 相关列表预填充脚本,我能够得到项目自动选择列表。我修改了脚本以添加一些附加功能:

- 现在使用弹出的新项目对话框而不是切换到新项目页面。
-现在适用于公告列表和文档库(文档库需要将 javascript 添加到编辑表单而不是新表单中)。
- 将填充 SelectedID URL 参数,当列表首次加载时,这对我来说没有发生。

这是我修改后的脚本:
RLHelper-ParentDisplayForm.js

/*
SharePoint 2010 Related List Prefill Version 1.2
Call JQuery and this file from the parent list's view item page that contains related list web parts.
Instructions: http://code.google.com/p/sp2010-related-list-prefill/
RLHelper-ParentDisplayForm.js
*/
function getQuerystring(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

_spBodyOnLoadFunctionNames.push("updateSelection");
function updateSelection() {
    var selId = getQuerystring("SelectedID");
    if (isNaN(selId) === true) {
        SelectField('VIEW GUID GOES HERE','1');
    }
    return false;
}

RLHelper-ChildNewForm.js

/*
SharePoint 2010 Related List Pre-fill Version 1.2
Call JQuery and this file from the child list's new item page.
Instructions: http://code.google.com/p/sp2010-related-list-prefill/

RLHelper-ChildNewForm.js
*/
function getQuerystring(ji, fromParent) {
    var hu;
    if(fromParent){
        hu = parent.window.location.search.substring(1);
    }
    else{
        hu = window.location.search.substring(1);
    }
    var gy = hu.split("&");
    var i = 0;
    for (i=0;i<gy.length;i++) {
        var ft = gy[i].split("=");
        if (ft[0] === ji) {
            return ft[1];
        }
    }
}

function fillfromParent(childfield) {
    var dlg = getQuerystring("IsDlg", false);
    if (isNaN(dlg) === false && dlg == 1) {
        var SelId = getQuerystring("SelectedID", true);
        var parentid = SelId.match(/\d+$/);
        if (isNaN(parentid) === false && parentid > 0) {
            $("select[title="+childfield+"]").val(parentid);
        }
    }
}

Based on Corey Martins related lists prefill scripts I was able to get the project to auto-select for lists. I modified the scripts to add a few additional features:

-Now uses the popup new item dialogs rather than switching to the new item page.
-Now works with announcement lists and document libraries (document libraries need to have the javascript added to the edit form not the new form).
-Will populate the SelectedID URL parameter which was not happening for me when the list was first loaded.

Here are my modified scripts:
RLHelper-ParentDisplayForm.js

/*
SharePoint 2010 Related List Prefill Version 1.2
Call JQuery and this file from the parent list's view item page that contains related list web parts.
Instructions: http://code.google.com/p/sp2010-related-list-prefill/
RLHelper-ParentDisplayForm.js
*/
function getQuerystring(ji) {
    hu = window.location.search.substring(1);
    gy = hu.split("&");
    for (i=0;i<gy.length;i++) {
        ft = gy[i].split("=");
        if (ft[0] == ji) {
            return ft[1];
        }
    }
}

_spBodyOnLoadFunctionNames.push("updateSelection");
function updateSelection() {
    var selId = getQuerystring("SelectedID");
    if (isNaN(selId) === true) {
        SelectField('VIEW GUID GOES HERE','1');
    }
    return false;
}

RLHelper-ChildNewForm.js

/*
SharePoint 2010 Related List Pre-fill Version 1.2
Call JQuery and this file from the child list's new item page.
Instructions: http://code.google.com/p/sp2010-related-list-prefill/

RLHelper-ChildNewForm.js
*/
function getQuerystring(ji, fromParent) {
    var hu;
    if(fromParent){
        hu = parent.window.location.search.substring(1);
    }
    else{
        hu = window.location.search.substring(1);
    }
    var gy = hu.split("&");
    var i = 0;
    for (i=0;i<gy.length;i++) {
        var ft = gy[i].split("=");
        if (ft[0] === ji) {
            return ft[1];
        }
    }
}

function fillfromParent(childfield) {
    var dlg = getQuerystring("IsDlg", false);
    if (isNaN(dlg) === false && dlg == 1) {
        var SelId = getQuerystring("SelectedID", true);
        var parentid = SelId.match(/\d+$/);
        if (isNaN(parentid) === false && parentid > 0) {
            $("select[title="+childfield+"]").val(parentid);
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文