- 
                
                    
- 
                不美怎敢妄 初学数据Lv2 发表于2018-6-26 10:53 
场景概述:维下拉框设置参数类型为单位级次下拉框,不同用户查看的下拉内容不一样,设置下拉内容中的第一个节点为用户首次计算的参数默认值。
背景说明:通常情况下,将登录用户的某个属性设置为单位级次下拉框的下拉内容,然后通过宏表达式的方式,设置该下拉框参数的默认值。例如<#=login.userid#>,但由于数据特殊,不便于通过该方式实现,故需要设置第一个节点为默认值。
3个回答
                                            解决方案如下
编辑客户端脚本:
setTimeout(function() {
 var param = g_rptpage.calcParam.getParamByName("@gddw");
 if (!param.value) {
  _f1(param);
 }
}, 300);
function _f1(param) {
 if (!param) {
  return;
 }
 param._initDropDownDom = function() {
  this.hasInitDropDownDom = true;
  // 设置过滤框事件
  $(this.filter.getEdit()).bind("keydown", function(e) {
   if (e.keyCode == 13) {
    this._inputFilterEvent();
    return false;
   }
  }.bind(this));
  // 设置按钮事件
  $(this.filter.getButton()).bind("click", function(e) {
   this._inputFilterEvent();
  }.bind(this));
  // 设置多选框事件
  $(this.allcheck).bind("click", this._checkAllEvent.bind(this));
  // 设置url
  this.tree.setQueryUrl(this.url);
  // 设置展开事件
  this.tree.getXTree().getXmlLoader().afterexpand = function() {
   // 自动调整宽度
   this.select.__adjustDropdownListBounds(true);
  }.bind(this);
  // 是否多选
  if (this.getIsmult()) {
   this.resultMap = new OrderMap();
   this.tree.getXTree().setOnCheck(this._treeOnCheck.bind(this));
   this.tree.onItem = function(item) {
    if (this.itemclickfilter
      && !this.evalItemClickEventFilter(item)) {
     item.showCheckBox(false);
    }
   }.bind(this);
  } else {
   this.tree.getXTree().setOnClick(this._treeOnClick.bind(this));
  }
  // 显示方式
  this.tree.setDisplayFunc(function(r) {
   return this._getDisplay(r.name, r.caption ? r.caption : r.name);
  }.bind(this));
  // 节点选择
  if (!this.itemclickfilter) {
   this.tree.getXTree().enableAutoCheckSubItems(this.getIsmult());
   this.tree.getXTree().enableAutoCheckGrayParent(this.getIsmult());
  }
  // 参数类型
  if (this.paramtype == "dim") {
   this._buildDim();
  } else if (this.paramtype == "bbh") {
   this._buildBbh();
  } else if (this.paramtype == "bbq") {
   this._buildBbq();
  }
  // 加载
  this.refreshItem(function() {
   var item = this.tree.getXTree().getRootItem().getChildItem(0);
   this.tree.getXTree().selectItem(item, true);
  }.bind(this));
 };
 param.select._initDropDownDom = function(fdiv) {
 };
 param.__initDropdownDom();
}
脚本使用说明:
 
该功能适用于单位级次下拉框,在门户里或者直接在浏览器里访问报表链接来用,如使用链接访问的方式的话加showparams=true参数,也就是以简洁模式进入。
另外,由于该脚本在结果表中才执行,故需计算一次之后才有效果,所以建议在使用时链接加自动计算参数calcnow=true。
                                    
小亿 发表于 2018-6-26 10:56
解决方案如下
编辑客户端脚本:
setTimeout(function() {
大佬可以说一下下拉框的tree.getXTree().selectItems(),这方法如何使用呢,我看到只传了一个参数,是传一个数组[a,b]还是MAP过去啊?
swxdi 发表于 2019-6-14 16:32
大佬可以说一下下拉框的tree.getXTree().selectItems(),这方法如何使用呢,我看到只传了一个参数,是传一 ...
这个脚本貌似是只改参数名称就可以用了把 看下那些注意事项
 



 
                        