2016-05-12 1 views
0

jqgridの行を編集する必要がありますが、データは複数行になります。ビューモードでは複数の行にデータを表示するために、私は複数行のテキストをアンラップするjqgridのEDITケース

function myformatter (cellvalue, options, rowObject) 
     { 
      return cellvalue.split(' ').join('<br/>'); 
     } 

を追加しましたが、私は行を編集するときに、今、私は
タグを見て、再び値は1行に表示されます。誰かが編集モードで1つのセルに新しい行に電子メールを表示するのを助けることができますか?

私のグリッドコード:

   $(function() { 



      var mydata =[{ 
       "email": "[email protected] [email protected] [email protected] [email protected]", 
       "name": "abc, def", 
       "address": "USA1" 

      }, 
      { 
       "email": "[email protected] [email protected] [email protected] [email protected]", 
       "name": "abSFc, def", 
       "address": "USA2" 
      }, 
     { 
      "email": "[email protected]", 
      "name": "abc, def", 
      "address": "USA3" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "aDbc, def", 
      "address": "UK4" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "FDabc, def", 
      "address": "UK5" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "abc, def", 
      "address": "UK6" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "aDbc, def", 
      "address": "UK7" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "abc, def", 
      "address": "USA8" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "abwqewfdec, def", 
      "address": "USA9" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "awvferbc, def", 
      "address": "USA88" 
     }, 
     { 
      "email": "[email protected]", 
      "name": "abwvfwc, def", 
      "address": "USA" 
     }]; 
        var lastsel;    
        $("#list").jqGrid({ 
         datatype: 'local', 
         data: mydata, 
         colNames: ['Email', 'Name', 'Address'], 
        colModel: [ 
       { name: 'email', width: 250, align: 'center',editable: true,formatter:myformatter 

       }, 
       { name: 'name', width: 150, align: 'center',editable: true 
          }, 
       { name: 'address', width: 150, editable: true} 

      ], 
       rowList:[10,20,20], 
     rowNum:15, 
       pager: '#pager', 

      gridview: true, 
      viewrecords: true, 
      height: '100%', 
      width: '50%', 
      search:true, 
      loadonce: true, 
      'cellEdit': true, 
      //toppager: true, 
      viewrecords: true,  
      caption: 'Grid with rowSpan attributes', 
      editurl: '/Home/GetStudents/', 

     gridComplete: function() { 
         var grid = this; 

         var filters, i, l, rules, rule, iCol, $this = $("#list"); 

         if (this.p.search === true) { 

          filters = $.parseJSON(this.p.postData.filters); 
          if (filters !== null && typeof filters.rules !== 'undefined' && 
            filters.rules.length > 0) { 
           rules = filters.rules; 
           l = rules.length; 

           for (i = 0; i < l; i++) { 
            rule = rules[i]; 
            $('body').highlight(rule.data); 
           } 
          } 
         } 

        /* var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length; 
         for (i = 0; i < l; i++) { 
          $this.jqGrid('editRow', ids[i], true); 
         } */ 
        } 
     }); 

        var lastSelection; 

        function editRow(id) { 
         if (id && id !== lastSelection) { 
          var grid = $("#list"); 
          grid.jqGrid('restoreRow',lastSelection); 
          grid.jqGrid('editRow', id, true); 
         // grid.jqGrid('editRow',id, {keys: true}); 
          lastSelection = id; 
         } 
        } 

        $("#list").jqGrid('filterToolbar',{stringResult: true, searchOnEnter : false , defaultSearch: 'cn', ignoreCase: true}); 
     //      
        function myformatter (cellvalue, options, rowObject) 
        { 
         return cellvalue.split(' ').join('<br/>'); 
        } 
     }); 

答えて

1

は "\\ n" はへ> </BRを置き換える新しい行を使用してみてください。

return cellvalue.split(' ').join('\\n'); 
+0

私はそれを試みましたが、私がセルを編集すると、ハイライトプラグインからのスパンが表示されるようになりました。とにかくありがとう – Danger009

関連する問題