1. 程式人生 > >Extjs中GridPanel實現單元格自動換行的補充-轉載

Extjs中GridPanel實現單元格自動換行的補充-轉載

Extjs中GridPanel實現單元格自動換行的補充

   
在Extjs中GridPanel元件或EditorGridPanel中,針對單元格內容超長實現自動換行要求時,目前網上介紹的基本上是在採用在ColumnModel中給對應列增加Css樣式,如下程式碼: ... {     id:'N_Pro_TestValue',     header:F_N_Pro_TestValue,     width: 120,     dataIndex:'N_Pro_TestValue',     menuDisabled:true, css:'background-color:#F5F5F5;',     renderer:function(value, meta, record) {        meta.attr ='style="white-space:normal;"'; 實現自動換行功能
       return value     } }, ... 但筆者在使用 EditorGridPanel中,發現該類換行有時候沒有達到預期效果,如圖


圖中對應的列,劃圈的部分實現了換行功能,但是畫矩形框部分,確沒有換行。 如果想要改部分也實現自動換行,需要對原來的CSS進行調整,增加word-wrap: break-word; 該行程式碼,即: ...  renderer: function(value, meta, record){        meta.attr ='style="white-space:normal;word-wrap:break-word;"'; 
       return value     } ... 這樣達到預期效果。

以上在extjs3.41版本中通過。 -------------------- 補充:在4.2.3版本中,以上程式碼改為: renderer : function (value, meta, record) { meta.style = 'white-space:normal;word-break:break-all;'; return value; }


轉自:
http://blog.sina.com.cn/s/blog_6543cca50102vzyd.html