dwz selectAnddialogs联合使用

来源:互联网 发布:程序员用哪个工具多 编辑:程序博客网 时间:2024/06/14 04:32
dwz富客户端框架默认实例有批量删除功能,通过选择checkbox在a标签里加入target="selectedTodo"(如果是dialog里的列表还需要加targetType="dialog")调用dwz.database.js的selectedTodo方法实现。可是它的修改并不是通过选择checkbox来实现,原来做的项目都是通过选择框来做修改和其他操作,于是在dwz.ui.js扩展了方法

//selectOne
 $("a[target=selectOne]",$p).each(function(){
  
  $(this).click(function(event){
   var $this =$(this);
   var title =$this.attr("title") || $this.text();
   var rel =$this.attr("rel") || "ids";
   
   vartargetType = $this.attr("targetType");
   var ids ="";
   var $box =targetType == "dialog" ? $.pdialog.getCurrent() :navTab.getCurrentPanel();
   $box.find("input:checked").filter("[name='"+rel+"']").each(function(i){
    varval = $(this).val();
    ids+= i==0 ? val : ","+val;
   });
   if (!ids){
    alertMsg.error($this.attr("warn")|| DWZ.msg("alertSelectMsg"));
    returnfalse;
   }

可以删除以下红色部分,便可选择多条信息

   if(ids.indexOf(',')!=-1) {
 
   alertMsg.error("只能选择一条信息");
 
   returnfalse;
 
  }
   
   var options ={};
   var w =$this.attr("width");
   var h =$this.attr("height");
   if (w)options.width = w;
   if (h)options.height = h;
   options.max =eval_r($this.attr("max") || "false");
   options.mask= eval_r($this.attr("mask") || "false");
   options.maxable= eval_r($this.attr("maxable") || "true");
   options.minable= eval_r($this.attr("minable") || "true");
   options.fresh= eval_r($this.attr("fresh") || "true");
   options.resizable= eval_r($this.attr("resizable") || "true");
   options.drawable= eval_r($this.attr("drawable") || "true");
   options.close= eval_r($this.attr("close") || "");
   options.param= $this.attr("param") || "";

   var url =($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first"));
   url = url +"?id="+ids;
   
   DWZ.debug(url);
   if(!url.isFinishedTm()) {
    alertMsg.error($this.attr("warn")|| DWZ.msg("alertSelectMsg"));
    returnfalse;
   }
   $.pdialog.open(url,rel, title, options);
   
   returnfalse;
  });
 })

这样在a标签里加入target="selectOne"就可以判断是否选择checkbox和只选择了一个checkbox,做相应操作。

0 0