解決jQuery的EasyUI的datagrid數據表格中行的垂直居中問題。


默認jQuery EasyUI的datagrid的行的垂直方向上的對齊是text-top的。效果是這樣:

 

修改后效果是這樣:

 

解決辦法:

datagrid只有align屬性,指的是水平方向的對齊方式,可以按照下面的方法設置css:

在創建datagrid的時候設置column的styler:

columns:[[
                        
                        {field:'監測網站',title:'監測網站',width:80,align:'center',
                            styler: function(value,row,index){
                                    return 'vertical-align:middle;';
                            }
                        }
      ]]

 

官方對styler的解釋:

 

Name Type Description Default
       
styler function The cell styler function, return style string to custom the cell style such as 'background:red'. The function take three parameter:
value: the field value.
rowData: the row record data.
rowIndex: the row index.

Code example:

$('#dg').datagrid({
	columns:[[
		{field:'listprice',title:'List Price', width:80, align:'right',
			styler: function(value,row,index){
				if (value < 20){
					return 'background-color:#ffee00;color:red;';
				}
			}
		}
	]]
});
undefined
       

 

官方地址


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM