2017-03-14 8 views
0

JSGridで値がtrueまたはfalseであるかどうかに基づいてアイコン(ロック)を追加しようとしています。JSGridは、真または偽の値に基づいてテキストの代わりにアイコンを追加します。

私はSoftLockと呼ばれる変数を持っています。これが真であれば、グリッドにロックアイコンを挿入したいと思います。

私は、次のフィールドを持っていますが、継続する方法について不明な点が午前:

var fields = [ 
         { name: 'ID', type: 'text', visible: false }, 
//THIS FIELD BELOW 
         { name: 'SoftLock', type: 'text', title: 'Locked', formatter : function() {return "<span class='fa fa-lock'><i class='fa fa-lock' aria-hidden='true'></i></span>"} }, 
//THIS FIELD ABOVE 
         { name: 'Status', type: 'select', items: MatterStatusEnum.List, valueField: 'Id', textField: 'Name', width: 70, title: 'Account Status' }, 
         { name: 'AttorneyRef', type: 'text', title: 'Reference' }, 
         { name: 'Investors', type: 'text', title: 'Investor/s' }, 
         { name: 'AccountNumber', type: 'text', width: 70, title: 'Account Number' }, 
         { name: 'IntermediaryName', type: 'text', title: 'Intermediary Name' }, 
         { name: 'CreatedBy', type: 'text', title: 'Captured By' }, 
         { name: 'RequestedDate', type: 'date', title: 'Requested Date'} 
       ]; 

私は運とフォーマッタを使用していました。また、trueの場合はアイコンを表示し、falseの場合は表示しません。

ご協力いただければ幸いです。

答えて

1

次のように私はitemTemplateを使用してこれを解決:

そのような単純な
{ name: 'SoftLock', type: 'text', title: 'Locked', width: 30, itemTemplate : function (value, item) { 
          var iconClass = ""; 
          if (value == true) { 
           iconClass = "fa fa-lock"; //this is my class with an icon 
          } 
          return $("<span>").attr("class", iconClass); 
         } 
         }, 

:)

関連する問題