Roo/bootstrap/form/MultiLineTag.js
authorleon <leon@roojs.com>
Wed, 1 Nov 2023 08:45:31 +0000 (16:45 +0800)
committerleon <leon@roojs.com>
Wed, 1 Nov 2023 08:45:31 +0000 (16:45 +0800)
roojs-bootstrap.js
roojs-bootstrap-debug.js

Roo/bootstrap/form/MultiLineTag.js
roojs-bootstrap-debug.js
roojs-bootstrap.js

index d0c4c79..5113e10 100644 (file)
@@ -212,11 +212,9 @@ Roo.extend(Roo.bootstrap.form.MultiLineTag, Roo.bootstrap.form.Input,  {
 
         // set new tags
         var arr = JSON.parse(json);
-        
+
         for (var i = 0; i < arr.length; i ++) {
-            if(this.tagRows.length == i) {
-                this.addTagRow();
-            }
+            this.addTagRow();
             this.tagRows[i].inputCb.setRawValue(arr[i][this.valueField]);
         }
         
index 4502aa1..264ed86 100644 (file)
@@ -14956,21 +14956,21 @@ Roo.extend(Roo.bootstrap.form.MultiLineTag, Roo.bootstrap.form.Input,  {
 
     setValue : function(json)
     {
-        // var arr = JSON.parse(json);
-        // var i = 0;
-        // for (; i < arr.length; i ++) {
-        //     if(this.tagRows.length == i) {
-        //         this.addTagRow();
-        //     }
-        //     this.tagRows[i].inputCb.setRawValue(arr[i][this.valueField]);
-        // }
 
+        // remove all old tags
         var oldTotal = this.tagRows.length;
 
         for(var i = 0; i < oldTotal; i ++) {
             this.removeTagRow(this.tagRows[0]);
         }
-        
+
+        // set new tags
+        var arr = JSON.parse(json);
+
+        for (var i = 0; i < arr.length; i ++) {
+            this.addTagRow();
+            this.tagRows[i].inputCb.setRawValue(arr[i][this.valueField]);
+        }
         
     }
 });
index 6a4e3de..6304809 100644 (file)
@@ -634,7 +634,7 @@ Roo.bootstrap.form.MultiLineTag=function(A){Roo.bootstrap.form.MultiLineTag.supe
 });}}};this.tagRows.push(this.addxtype(D));A.showHideRemoveBtn();},shouldAutoAddTagRow:function(){var A=true;Roo.each(this.tagRows,function(r){if(r.inputCb.getRawValue()==''){A=false;}});return A;},removeTagRow:function(A){A.destroy();this.tagRows.splice(this.tagRows.indexOf(A),1);
 this.fireEvent('change',this,this.getValue(),false);this.showHideRemoveBtn();},showHideRemoveBtn:function(){var A=this;Roo.each(this.tagRows,function(r){r.removeBtn.show();if(A.tagRows.length<=A.minimumRow){r.removeBtn.hide();}});},getValue:function(){var A=this;
 var B=[];Roo.each(A.tagRows,function(r){var C=r.inputCb.getRawValue();if(C!=''){var D={};D[A.valueField]=r.inputCb.getRawValue();B.push(D);}});return JSON.stringify(B);},setValue:function(A){var B=this.tagRows.length;for(var i=0;i<B;i++){this.removeTagRow(this.tagRows[0]);
-}}});
+}var C=JSON.parse(A);for(var i=0;i<C.length;i++){this.addTagRow();this.tagRows[i].inputCb.setRawValue(C[i][this.valueField]);}}});
 // Roo/data/SortTypes.js
 Roo.data.SortTypes={none:function(s){return s;},stripTagsRE:/<\/?[^>]+>/gi,asText:function(s){return String(s).replace(this.stripTagsRE,"");},asUCText:function(s){return String(s).toUpperCase().replace(this.stripTagsRE,"");},asUCString:function(s){return String(s).toUpperCase();
 },asDate:function(s){if(!s){return 0;}if(s instanceof Date){return s.getTime();}return Date.parse(String(s));},asFloat:function(s){var A=parseFloat(String(s).replace(/,/g,""));if(isNaN(A)){A=0;}return A;},asInt:function(s){var A=parseInt(String(s).replace(/,/g,""));