Sharepoint 2010 默认新建子列表项到选定父列表项

Sharepoint 2010 默认新建子列表项到选定父列表项,sharepoint-2010,default,parent-child,Sharepoint 2010,Default,Parent Child,我有一个名为项目的Sharepoint列表和另一个名为任务的列表。“任务”列表有一个指向“项目”列表标题的查找字段,以便我可以使用“插入相关列表”选项。插入相关列表后,选择项目将仅显示与该项目关联的任务。 如何使任务列表在添加新任务时将默认项目查找值设置为当前选定的项目?基于Corey Martins,我能够使项目自动选择列表。我修改了脚本以添加一些附加功能: -现在使用弹出的“新建项目”对话框,而不是切换到“新建项目”页面。 -现在可用于公告列表和文档库文档库需要将javascript添加到编

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

基于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);
        }
    }
}

如何定义当前选定的项目?按url,查询字符串?添加相关列表时,项目列表将获得一个名为“选择”的新列。单击此列中的一个双箭头选择该行中的项目。