2014-08-29 8 views
7

मैं अपने ऐप में ExtJS के साथ FontAwesome का उपयोग कर रहा हूं।फ़ॉन्ट-विस्मयकारी ExtJS ActionColumn

सभी अन्य बटन फ़ॉन्ट भयानक के साथ ठीक काम कर रहा है जब मैं यह कर रहे हैं:

iconCls: 'fa fa-edit' 

उदाहरण के लिए।

लेकिन जब कार्रवाई क्रिया में एक ही कॉन्फ़िगरेशन का उपयोग करते हैं (घटक जो आपको ग्रिड पर पु बटन करने की अनुमति देता है) आइकन बस प्रकट नहीं होता है।

क्या किसी को पता है क्यों? ?

संपादित

@qdev जवाब की कोशिश के बाद: मैं बस एक # f040 दिखाई दे रही है; पाठ प्रस्तुत (नीले रंग में)।

कार्रवाई स्तंभ बटन के लिए उत्पन्न HTML:

<span data-qtip="Edita registro" style="font-family:FontAwesome" class="x-action-col-icon x-action-col-glyph x-action-col-2 " title="" role="button">�xf040;</span> 

सीएसएस (firebuh निरीक्षक से लिया):

element.style { 
    font-family: FontAwesome; 
} 
*, *:before, *:after { 
    box-sizing: border-box; 
} 
*, *:before, *:after { 
    box-sizing: border-box; 
} 
.x-action-col-icon { 
    cursor: pointer; 
    height: 16px; 
    width: 16px; 
} 
.x-border-box, .x-border-box * { 
    box-sizing: border-box; 
} 
.x-action-col-glyph { 
    color: #9bc8e9; 
    font-size: 16px; 
    line-height: 16px; 
    width: 20px; 
} 
*, *:before, *:after { 
    box-sizing: border-box; 
} 
element.style { 
    text-align: center; 
} 
.x-grid-cell-inner-action-col { 
    font-size: 0; 
    line-height: 0; 
} 
.x-grid-cell-inner { 
    white-space: nowrap; 
} 
.x-grid-cell { 
    font: 11px/13px tahoma,arial,verdana,sans-serif; 
} 
.x-unselectable { 
    cursor: default; 
} 
.x-grid-table { 
    border-collapse: separate; 
} 
.x-unselectable { 
    cursor: default; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-panel-body-default { 
    color: black; 
    font-size: 12px; 
} 
.x-body { 
    color: black; 
    font-family: tahoma,arial,verdana,sans-serif; 
    font-size: 12px; 
} 
body { 
    color: #222222; 
    cursor: default; 
    font-family: "Helvetica Neue","Helvetica",Helvetica,Arial,sans-serif; 
    font-style: normal; 
    font-weight: normal; 
    line-height: 150%; 
} 
html, body { 
    font-size: 100%; 
} 
html, body { 
    font-size: 100%; 
} 

उत्तर

18

यह है जो आइकन को स्वीकार करता है क्योंकि ग्रिड कार्रवाई स्तंभ माउस IMG टैग के रूप में प्रदान कर रहे हैं (पथ) विकल्प के रूप में।

आदेश में इस का उपयोग करने में सक्षम हो, तो आप Ext.grid.column.Action*defaultRenderer* विधि ओवरराइड करने के लिए, आइकन के पास ग्लिफ़ config विकल्प का समर्थन करने के लिए (है और अपने कोड पर आप बल्कि तय कर सकते हैं कि आप किसी भी दृश्य पर प्रत्येक कार्य के लिए आइकन img या glyph साथ जाना ।)

काम कर (ExtJS 5.0.1 पर परीक्षण किया लेकिन मैं इसे ExtJS 4 रूप में अच्छी तरह पर काम करता है लगता है) इस ओवरराइड के लिए कोड:

Ext.define('MyApp.overrides.grid.column.Action', { 
    override: 'Ext.grid.column.Action', 

    // overridden to implement 
    defaultRenderer: function(v, meta, record, rowIdx, colIdx, store, view){ 
     var me = this, 
      prefix = Ext.baseCSSPrefix, 
      scope = me.origScope || me, 
      items = me.items, 
      len = items.length, 
      i = 0, 
      item, ret, disabled, tooltip, glyph, glyphParts, glyphFontFamily; 

     // Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!) 
     // Assign a new variable here, since if we modify "v" it will also modify the arguments collection, meaning 
     // we will pass an incorrect value to getClass/getTip 
     ret = Ext.isFunction(me.origRenderer) ? me.origRenderer.apply(scope, arguments) || '' : ''; 

     meta.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell'; 
     for (; i < len; i++) { 
      item = items[i]; 

      disabled = item.disabled || (item.isDisabled ? item.isDisabled.call(item.scope || scope, view, rowIdx, colIdx, item, record) : false); 
      tooltip = disabled ? null : (item.tooltip || (item.getTip ? item.getTip.apply(item.scope || scope, arguments) : null)); 
      glyph = item.glyph; 

      // Only process the item action setup once. 
      if (!item.hasActionConfiguration) { 

       // Apply our documented default to all items 
       item.stopSelection = me.stopSelection; 
       item.disable = Ext.Function.bind(me.disableAction, me, [i], 0); 
       item.enable = Ext.Function.bind(me.enableAction, me, [i], 0); 
       item.hasActionConfiguration = true; 
      } 

      if (glyph) { 
       if (typeof glyph === 'string') { 
        glyphParts = glyph.split('@'); 
        glyph = glyphParts[0]; 
        glyphFontFamily = glyphParts[1]; 
       } else { 
        glyphFontFamily = Ext._glyphFontFamily; 
       } 

       ret += '<span role="button" title="' + (item.altText || me.altText) + '" class="' + prefix + 'action-col-icon ' + prefix + 'action-col-glyph ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + 
        ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + 
        ' style="font-family:' + glyphFontFamily + '"' + 
        (tooltip ? ' data-qtip="' + tooltip + '"' : '') + '>&#' + glyph + ';</span>'; 
      } else { 
       ret += '<img role="button" alt="' + (item.altText || me.altText) + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) + 
        '" class="' + prefix + 'action-col-icon ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + 
        ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + 
        (tooltip ? ' data-qtip="' + tooltip + '"' : '') + ' />'; 
      } 
     } 
     return ret;  
    } 
}); 

आप जहां डाल करने के लिए पता नहीं है या, आप इसे लोड इंटरनेट पर पा सकते हैं, लेकिन एक सेन्चा cmd जेनरेट किए गए ऐप पर आप इसे appFolder/overrides/grid/column/Action.js में डाल दें और स्वचालित रूप से ढांचे से लोड हो जाएंगे।

फिर आपको कुछ सीएसएस को भी ट्विक करना होगा (मैंने मुख्य व्यूपोर्ट के लिए अपने कस्टम सीएसएस में जोड़ा है)। इस के बिना आप glyps नहीं देखेंगे, मुझे लगता है कि आप समझते हैं क्यों bellow कोड देख लेंगे: सभी पंक्तियों और शो के लिए डिफ़ॉल्ट रूप से छुपाने के लिए कार्रवाई प्रतीक:

.x-action-col-glyph {font-size:16px; line-height:16px; color:#9BC8E9; width:20px} 
.x-action-col-glyph:hover{color:#3892D3} 

मैं भी एक और अच्छा चाल करने के लिए सफल रहा है उन्हें केवल घुमावदार पंक्ति/रिकॉर्ड पर।

{ 
    glyph: 0xf055, 
    tooltip: 'Add', 
    getClass: function(){return 'x-hidden-display'} 
} 
:

आप जहां केवल विचारों कि आप x-hidden-display जोड़कर आइकन/ग्लिफ़ की getClass config फ़ंक्शन का उपयोग करके wwant पर इसका उपयोग करने, इस तरह वर्ग (पुराने ExtJS संस्करण पर x-hide-display हो सकता है) चुन सकते हैं

...और फिर सीएसएस आगे पीछे करता/चयनित पंक्ति का उपयोग कर के लिए ही सभी चिह्न दिखाने:

.x-grid-item-over .x-hidden-display, .x-grid-item-selected .x-hidden-display{display:inline-block !important} 

मुझे आशा है कि इस मदद करता है;)

+0

मैं छुट्टी का दिन पर हूँ। सोमवार मैं इसमें देखूंगा और आपको कुछ फीडबैक प्राप्त करूंगा। धन्यवाद। – lcguida

+0

ठीक है, सोमवार को पारित किया गया, क्या आपको इसका परीक्षण करने का मौका मिला? मैं उत्सुक था;) – qdev

+0

क्षमा करें। केवल आज ही इसका परीक्षण कर सकता है। मुझे आइकन नहीं मिल रहा है, लेकिन एक? X0f40; इसके बजाय पाठ। मैं इसे FontAwesome का उपयोग कर फ़ॉन्ट के रूप में देख सकता हूं। लेकिन आइकन प्रस्तुत नहीं कर रहा है। (से मेरा अद्यतन प्रश्न) – lcguida

1

मैं हाल ही में आप कस्टम चिह्न तैयार करने के लिए मदद मिलेगी इस नए एप्लिकेशन बना लिया है कि आप iconCls को असाइन कर सकते हैं। यह आपके सेन्चा ऐप्स के लिए _icons.scss फ़ाइल उत्पन्न करता है। मैंने इसे केवल सेन्चा टच के साथ परीक्षण किया है, लेकिन मुझे लगता है कि इसे एक्स्टजेस के साथ भी काम करना चाहिए। रीडमे इको चंद्रमा वेबसाइट पर आइकन बनाने और इको चंद्रमा परियोजना फ़ाइलों को सेन्चा में उपयोग के लिए एससीएसएस में परिवर्तित करने के लिए टूल का उपयोग करने के लिए कदम बताता है। इसका परीक्षण सेन्चा आर्किटेक्ट टच परियोजनाओं के साथ किया गया है।

आप ExtJS के लिए इसका इस्तेमाल करते हैं, तो कृपया मुझे बताओ अगर यह काम करता है। धन्यवाद।

2

मैं qdev समाधान के लिए (प्रतीक के लिए getClass को समान) getGlyph जोड़ें। यह बहुत आसान समाधान है लेकिन सही काम करता है।

if(Ext.isFunction(item.getGlyph)){ 
     glyph = item.getGlyph.apply(item.scope || scope, arguments); 
    }else{ 
     glyph = item.glyph; 
    } 

पूरा ओवरराइड कोड:

Ext.define('corporateCms.overrides.grid.column.Action', { 
    override: 'Ext.grid.column.Action', 

    // overridden to implement 
    defaultRenderer: function(v, cellValues, record, rowIdx, colIdx, store, view) { 
     var me = this, 
      prefix = Ext.baseCSSPrefix, 
      scope = me.origScope || me, 
      items = me.items, 
      len = items.length, 
      i = 0, 
      item, ret, disabled, tooltip,glyph, glyphParts, glyphFontFamily; 

     // Allow a configured renderer to create initial value (And set the other values in the "metadata" argument!) 
     // Assign a new variable here, since if we modify "v" it will also modify the arguments collection, meaning 
     // we will pass an incorrect value to getClass/getTip 
     ret = Ext.isFunction(me.origRenderer) ? me.origRenderer.apply(scope, arguments) || '' : ''; 

     cellValues.tdCls += ' ' + Ext.baseCSSPrefix + 'action-col-cell'; 
     for (; i < len; i++) { 
      item = items[i]; 

      disabled = item.disabled || (item.isDisabled ? item.isDisabled.call(item.scope || scope, view, rowIdx, colIdx, item, record) : false); 
      tooltip = disabled ? null : (item.tooltip || (item.getTip ? item.getTip.apply(item.scope || scope, arguments) : null)); 
      if(Ext.isFunction(item.getGlyph)){ 
       glyph = item.getGlyph.apply(item.scope || scope, arguments); 
      }else{ 
       glyph = item.glyph; 
      } 

      // Only process the item action setup once. 
      if (!item.hasActionConfiguration) { 
       // Apply our documented default to all items 
       item.stopSelection = me.stopSelection; 
       item.disable = Ext.Function.bind(me.disableAction, me, [i], 0); 
       item.enable = Ext.Function.bind(me.enableAction, me, [i], 0); 
       item.hasActionConfiguration = true; 
      } 
      if (glyph) { 

       if (typeof glyph === 'string') { 
        glyphParts = glyph.split('@'); 
        glyph = glyphParts[0]; 
        glyphFontFamily = glyphParts[1]; 
       } else { 
        glyphFontFamily = Ext._glyphFontFamily; 
       } 

       ret += '<span role="button" title="' + (item.altText || me.altText) + '" class="' + prefix + 'action-col-icon ' + prefix + 'action-col-glyph ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + 
        ' ' + (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + 
        ' style="font-family:' + glyphFontFamily + '"' + 
        (tooltip ? ' data-qtip="' + tooltip + '"' : '') + '>&#' + glyph + ';</span>'; 
      } else { 
       ret += '<img role="button" alt="' + (item.altText || me.altText) + '" src="' + (item.icon || Ext.BLANK_IMAGE_URL) + 
        '" class="' + me.actionIconCls + ' ' + prefix + 'action-col-' + String(i) + ' ' + (disabled ? prefix + 'item-disabled' : ' ') + 
        (Ext.isFunction(item.getClass) ? item.getClass.apply(item.scope || scope, arguments) : (item.iconCls || me.iconCls || '')) + '"' + 
        (tooltip ? ' data-qtip="' + tooltip + '"' : '') + ' />'; 
      } 
     } 
     return ret; 
    }  
}); 

आप उपयोग कर सकते हैं यह उतना ही आसान है:

getGlyph: function(v, meta, rec) { 
     if (rec.get('access')) { 
      return '[email protected]'; 
     } else { 
      return '[email protected]'; 
     } 
    }, 

मैं इस आशा

है सिर्फ 3 लाइनों qdev कर समाधान को जोड़ने है आपकी मदद करता है;)

0

ऐसा लगता है कि अगर आप 4.0 - 4.1 में हैं तो ओवरराइड काम नहीं करते हैं। मैं कम से कम प्रतिरोध का मार्ग चला गया और सिर्फ http://fa2png.io/ के माध्यम से आइकन को पीएनजी प्रारूप में बनाया, फिर निर्दिष्ट वर्ग को सीएसएस में पृष्ठभूमि-छवि यूआरएल में परिभाषित किया।

2

आप बस निम्नलिखित के रूप में लौट सकते हैं 'पिता पिता-संपादन' actioncolumn आइटम की getClass से वर्ग:

{ 
    xtype: 'actioncolumn', 
    items: [{ 
     getClass: function() { 
      return 'x-fa fa-users'; 
     } 
    }] 
}