我们可以将搜索配置为在选择搜索功能时自动打开吗,我以为可以通过配置来实现,但我找不到可以配置它的位置。 它已经在 https://www.ibm.com/developerworks/community/forums/html/topic?id=fbac6330-f636-4745-924a-a713f4f9a309&ps=50&tags=&query=&filter=&sortBy=&order=asc 但是没有答案怎么做,只有建议:"你可以用插件编码。 如何使用插件完成此操作?
我在互联网上没有找到答案。我能够自己编码。希望它能帮助其他人。
我做了 ContentNavigator Dojo class ecm/widget/search/SearchSelector 的猴子修补
请参阅下面的代码:
var searchSelectorPrototype = searchSelector.prototype;
var old_createTree = searchSelectorPrototype._createTree;
searchSelectorPrototype._createTree = function () {
old_createTree.apply(this, arguments);
this._tree.expandAll();// we need to expand tree to be able to get search templates by _tree.getNodesByItem("all")[0].getChildren();
var that = this;
var i = 0;
var myVar = setInterval(myTimer ,100);//need to wait until expandAll() completed
function myTimer() {
i++;
var searchTemplates = that._tree.getNodesByItem("all")[0].getChildren();
if (i>50){
clearInterval(myVar);
console.log("not able to get search templates from _tree.getNodesByItem("all")[0].getChildren()");
}
if (searchTemplates.length > 0 ){
clearInterval(myVar);
new searchPlugin.config.PluginConfig().getConfiguration(// we need to know which search template to open, I added configuration parameter "autoSearchTemplateName" to plugin
function(response) {
var templateName;
response.configuration.forEach(function (configurationItem) {
if (configurationItem.name == 'autoSearchTemplateName'){
templateName = configurationItem.value;
}
});
array.forEach(searchTemplates, function(template){
if(template.item.name === templateName){
that.setSelected(template.item);
return false;
}
}, that);
},
function(response) {
console.error(response);
}
);
}
}
}