Explorar el Código

数据网格增加允许删除和允许添加选项

unknown hace 5 años
padre
commit
2a89115c9e

+ 17 - 0
o2web/source/x_component_process_FormDesigner/Module/Datagrid/datagrid.html

@@ -41,6 +41,23 @@
 
         <div class="MWFMaplist" name="properties" collapse="true" title="属性"></div>
         <div class="MWFScriptArea" name="defaultData" title="默认数据(S)"></div>
+
+        <table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
+            <tr>
+                <td class="editTableTitle">允许删除:</td>
+                <td class="editTableValue">
+                    <input type="radio" name="deleteable" value="yes" text{($.deleteable!=='no')?'checked':''}/>是
+                    <input type="radio" name="deleteable" value="no" text{($.deleteable==='no')?'checked':''}/>否
+                </td>
+            </tr>
+            <tr>
+                <td class="editTableTitle">允许添加:</td>
+                <td class="editTableValue">
+                    <input type="radio" name="addable" value="yes" text{($.addable!=='no')?'checked':''}/>是
+                    <input type="radio" name="addable" value="no" text{($.addable==='no')?'checked':''}/>否
+                </td>
+            </tr>
+        </table>
         <div class="MWFScriptArea" name="editableScript" title="是否可编辑(S)"></div>
 
         <div class="MWFValidation" name="validationConfig"></div>

+ 24 - 15
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -29,6 +29,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this);
         //this.editable = false;
 
+        this.deleteable = this.json.deleteable !== "no";
+        this.addable = this.json.addable !== "no";
+
         this.gridData = this._getValue();
 
         this.totalModules = [];
@@ -329,9 +332,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             }.bind(this));
         }else{
             if (this.addAction){
-                this.addAction.setStyle("display", "block");
+                if( this.addable )this.addAction.setStyle("display", "block");
             }else{
-                this._loadAddAction();
+                if( this.addable )this._loadAddAction();
             }
             // this._loadAddAction();
         }
@@ -341,18 +344,24 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         var actionNode = new Element("div", {
             "styles": this.form.css.mobileDatagridActionNode
         }).inject(titleDiv);
+
         var delAction = new Element("div", {
             "styles": this.form.css.mobileDatagridDelActionNode,
             "text": MWF.xApplication.process.Xform.LP["delete"]
         }).inject(actionNode);
+        if( !this.deleteable )delAction.hide();
+
         var editAction = new Element("div", {
             "styles": this.form.css.mobileDatagridEditActionNode,
             "text": MWF.xApplication.process.Xform.LP.edit
         }).inject(actionNode);
+
         var addAction = new Element("div", {
             "styles": this.form.css.mobileDatagridAddActionNode,
             "text": MWF.xApplication.process.Xform.LP.add
         }).inject(actionNode);
+        if( !this.addable )addAction.hide();
+
         var cancelAction = new Element("div", {
             "styles": this.form.css.mobileDatagridCancelActionNode,
             "text": MWF.xApplication.process.Xform.LP.cancelEdit
@@ -364,7 +373,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
 
         var _self = this;
-        delAction.addEvent("click", function(e){
+        if( this.deleteable )delAction.addEvent("click", function(e){
             _self._deleteLine(this.getParent().getParent().getParent(), e);
         });
         editAction.addEvent("click", function(e){
@@ -376,7 +385,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         cancelAction.addEvent("click", function(e){
             _self._cancelLineEdit(e);
         });
-        addAction.addEvent("click", function(e){
+        if( this.addable )addAction.addEvent("click", function(e){
             _self._addLine();
         });
     },
@@ -550,9 +559,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                 currentEditTable.setStyle("display", "table");
 
                 var actions = datagrid.currentEditLine.getFirst("div").getLast("div").getElements("div");
-                if (actions[0]) actions[0].setStyle("display", "block");
-                if (actions[1]) actions[1].setStyle("display", "block");
-                if (actions[2]) actions[2].setStyle("display", "block");
+                if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
+                if (actions[1] ) actions[1].setStyle("display", "block");
+                if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
                 if (actions[3]) actions[3].setStyle("display", "none");
                 if (actions[4]) actions[4].setStyle("display", "none");
 
@@ -567,9 +576,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
             if (!_self.gridData.data.length){
                 if (_self.addAction){
-                    _self.addAction.setStyle("display", "block");
+                    if( _self.addable )_self.addAction.setStyle("display", "block");
                 }else{
-                    _self._loadAddAction();
+                    if( _self.addable )_self._loadAddAction();
                 }
             }
 
@@ -601,9 +610,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             table = dataNode.getElement("table");
 
             var actions = this.currentEditLine.getFirst("div").getLast("div").getElements("div");
-            if (actions[0]) actions[0].setStyle("display", "block");
+            if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
             if (actions[1]) actions[1].setStyle("display", "block");
-            if (actions[2]) actions[2].setStyle("display", "block");
+            if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
             if (actions[3]) actions[3].setStyle("display", "none");
             if (actions[4]) actions[4].setStyle("display", "none");
         }else{
@@ -616,9 +625,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             }
 
             var actions = this.table.getParent().getPrevious("div").getLast("div").getElements("div");
-            if (actions[0]) actions[0].setStyle("display", "block");
+            if (actions[0] && this.deleteable ) actions[0].setStyle("display", "block");
             if (actions[1]) actions[1].setStyle("display", "block");
-            if (actions[2]) actions[2].setStyle("display", "block");
+            if (actions[2] && this.addable ) actions[2].setStyle("display", "block");
             if (actions[3]) actions[3].setStyle("display", "none");
             if (actions[4]) actions[4].setStyle("display", "none");
 
@@ -851,9 +860,9 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
                 if (!_self.gridData.data.length){
                     if (_self.addAction){
-                        _self.addAction.setStyle("display", "block");
+                        if( _self.addable )_self.addAction.setStyle("display", "block");
                     }else{
-                        _self._loadAddAction();
+                        if( _self.addable )_self._loadAddAction();
                     }
                 }
                 this.close();

+ 11 - 4
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -26,6 +26,9 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
         this.editable = (this.readonly) ? false : true;
         if (this.editable) this.editable = this.form.Macro.exec(((this.json.editableScript) ? this.json.editableScript.code : ""), this);
 
+        this.deleteable = this.json.deleteable !== "no";
+		this.addable = this.json.addable !== "no";
+
 		this.gridData = this._getValue();
 
         this.totalModules = [];
@@ -84,12 +87,16 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		
 		var actionTh = new Element("th", {"styles": {"width": "46px"}}).inject(this.titleTr, "top");
 		new Element("th").inject(this.titleTr, "bottom");
-		this._createAddLineAction(actionTh);
+		if( this.addable ){
+			this._createAddLineAction(actionTh);
+		}
 		//this._createDelLineAction(actionTh);
 		
 		var actionEditTd = new Element("td").inject(this.editorTr, "top");
 		this._createCompleteAction(actionEditTd);
-		this._createCancelAction(actionEditTd);
+		if( this.deleteable ){
+			this._createCancelAction(actionEditTd);
+		}
 		
 		new Element("td").inject(this.editorTr, "bottom");
 
@@ -202,8 +209,8 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		var cell = $(tr.insertCell(idx));
 		if (idx==0){
 			cell.setStyles(this.form.css.gridLineActionCell);
-			this._createAddLineAction(cell);
-			this._createDelLineAction(cell);
+			if( this.addable )this._createAddLineAction(cell);
+			if( this.deleteable )this._createDelLineAction(cell);
 		}else if (idx == lastIdx){
 			cell.setStyles(this.form.css.gridMoveActionCell);
 			this._createMoveLineAction(cell);