如何删除addPreSearch过滤器

use*_*914 4 crm dynamics-crm dynamics-crm-2011 dynamics-crm-4 dynamics-crm-2013

我想删除PreSearch文件管理器,我的代码如下.我怎样才能实现同样的目标?

Xrm.Page.getControl("productid").removePreSearch(function () {
    Object
});

Xrm.Page.getControl("productid").addPreSearch(function () {
    fetchxml2();
});

function fetchxml2() {
    var fetchXml1 = "<filter type='and'>"
    fetchXml1 += "<condition attribute='productid' operator='in' >";
    for (var i = 0; i < Itemid.length; i++) {
        fetchXml1 += "<value>" + Itemid[i] + "</value>";
    }

    fetchXml1 += "</condition>";
    fetchXml1 += "</filter>";
    Xrm.Page.getControl("productid").addCustomFilter(fetchXml1);
    //Xrm.Page.getControl("productid").removePreSearch(fetchXml1);

};
Run Code Online (Sandbox Code Playgroud)

p e*_*e p 8

为了能够通过移除处理程序removePreSearch,避免通过创建一个名为功能和使用,在这两种使用匿名函数addPreSearchremovePreSearch:

function preSearchHandler(){
    fetchxml2();
}

Xrm.Page.getControl("productid").removePreSearch(preSearchHandler);

Xrm.Page.getControl("productid").addPreSearch(preSearchHandler);
Run Code Online (Sandbox Code Playgroud)