方法一:設置css屬性(server module)
.x-column-header{/*表頭設置*/
color:black;/*字體顏色*/
font-size:13px;/*字體大小*/
height: 50px;/*表頭高度*/
border: none;/*表頭框線*/
background:#C1C1C1;//表頭背景*/
}
.GridLotacao .x-grid-column {/*帶元素id的屬性(設置欄),在unidbgrid中的layoutconfig屬性中的cls子屬性中加入GridLotacao名稱*/
height: 50px;
}
.GridLotacao .x-grid-cell {/*帶元素id的屬性(設置單元格),在unidbgrid中的layoutconfig屬性中的cls子屬性中加入GridLotacao名稱*/
height: 50px !important;
line-height: 50px !important;
}
方法二:代碼實現。
procedure TUniServerModule.UniGUIServerModuleCreate(Sender: TObject);
begin
// UniServerModule.CustomCSS.Clear; 這句會把css中的內容清掉
UniServerModule.CustomCSS.Add('.x-grid-cell {' + ' vertical-align: middle;' +// ' vertical-align: bottom;' +
'}');//設置單元格子中的文字居中
UniServerModule.CustomCSS.Add('.x-grid-cell-inner {' + ' line-height: 100%;' + '}');
end;
自動列寬。
function store.load(sender, records, successful, operation, eOpts)
{
sender.grid.columnManager.columns.forEach(function(col){col.autoSize()})
}
結果。