代码设置单据体背景颜色与字体颜色原创
金蝶云社区-拾柒_
拾柒_
13人赞赏了该文章 1739次浏览 未经作者许可,禁止转载编辑于2023年10月10日 10:39:56

关键词:

单据体,背景颜色,卡片分录背景颜色


一、设置单据体某一行某一个字段的背景色和字体颜色

AbstractGrid grid = this.getView().getControl("单据体标识");
ArrayList csList = new  ArrayList();
CellStyle cs = new CellStyle(); 
cs.setBackColor("#ff0000");//外边框颜色 
cs.setForeColor("#ff0000");//字体颜色 
cs.setFieldKey("分录字段标识");//列标识 
cs.setRow(0);//行索引
csList.add(cs); 
grid.setCellStyle(csList);//设置单元格样式

二、如果需要多次设置颜色,需要清空之前设置的背景色

AbstractGrid grid = this.getView().getControl("单据体标识");
grid.clearEntryState();

三、设置一整行的背景颜色样式

IClientViewProxy proxy = this.getView().getService(IClientViewProxy.class);
  ListRowStyleBuilder rowStyleBuilder = ClientActions.createRowStyleBuilder();
        //行索引
        rowStyleBuilder.setRows(new int[]{0,1});
        //前景色
        rowStyleBuilder.setForeColor("red");
        //背景颜色
        rowStyleBuilder.setBackColor("#ffd52e");
        rowStyleBuilder.buildStyle();
        rowStyleBuilder.build();
        rowStyleBuilder.invokeControlMethod(proxy, "单据体标识");

四、卡片分录设置字段前景色和背景色

private void setRowCellStyle(String key, int row) { 
 CardEntry cardEntry = this.getView().getControl(KEY_ENTRY_CARD);
  //结果必须正确,否则不生效 
  Map<String, Object> map_textfield = new HashMap<>(1);
  Map<String, Object> prop_textfield = new HashMap<>(1);
  //背景颜色  
  prop_textfield.put(ClientProperties.BackColor, "#44cef6");
  //前景颜色  
  prop_textfield.put(ClientProperties.ForeColor, "#76cbfc");  
  map_textfield.put(key, prop_textfield);
  //此方法只设置一些样式属性,不能圆角半径等属性  
  cardEntry.setCustomProperties(cardEntry.getKey(), row, map_textfield); 
}


赞 13