简体   繁体   English

如何获得ListGridRecord的Canvas组件?

[英]How can I get a Canvas component of a ListGridRecord?

I use smartgwt 2.4. 我使用smartgwt 2.4。

I'm trying to style a ListGridRecord . 我正在尝试设置ListGridRecord样式。 I want to get the Canvas component of it, but I cannot find a reference anywhere. 我想获取它的Canvas组件,但是在任何地方都找不到参考。

I know there are methods in ListGrid as createRecordComponent or getBackgroundComponent etc., but these don't return any component. 我知道ListGrid有一些方法,例如createRecordComponentgetBackgroundComponent等,但是这些方法不返回任何组件。 They are meant as an override point (user can define his/her own components instead of default). 它们被用作替代点(用户可以定义自己的组件而不是默认组件)。 But this is not what I want. 但这不是我想要的。 I want to get the default component and change it (style it). 我想获取默认组件并对其进行更改(设置其样式)。

I know there's a setCellFormatter method at the ListGrid , where I can set format of a cell, but it only regards the text component of a cell, not the whole row (record). 我知道有一个setCellFormatter在方法ListGrid ,在那里我可以设置单元格的格式,但它只是认为一个单元格的文本组件,而不是整个行(记录)。

I know there's a getBaseStyle method, where I can put a class name, but this is still not what I want. 我知道有一个getBaseStyle方法,可以在其中放置一个类名,但这仍然不是我想要的。 I want to change the style dynamically (eg I want to put any background color to the component) not only put a static class(es) (where the background color is predefined). 我想动态更改样式(例如,我想给组件添加任何背景色),而不仅是放置静态类(预定义背景色)。

Can anybody help? 有人可以帮忙吗? Thanks. 谢谢。

I'm afraid your options are a little limited when it comes to SmartGWT. 恐怕您在选择SmartGWT时会受到一些限制。 One, although not very simple way of achieving that is overriding the ListGrid.getCellCSSText(ListGridRecord record, int rowNum, int colNum) method on creation of ListGrid as shown here . 一,尽管实现这一目标的不是很简单的方法是重写ListGrid.getCellCSSText(ListGridRecord记录,诠释的rowNum,INT colNum)方法在创建ListGrid如图所示这里
That is how I have created customized cell styles. 这就是我创建自定义单元格样式的方式。

final ListGrid grid= new ListGrid() {
    protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {
        if (getFieldName(colNum).equals("MyColumnName")) {
            ListGridRecord record = (ListGridRecord) record;
            if (record.getSomeValue() > 20) {
                return "font-weight:bold; color:red;";
            } else if (record.getSomethingElse() < 5) {
                return "font-weight:bold; color:blue;";
            } else {
                return super.getCellCSSText(record, rowNum, colNum);
            }
        } else {
            return super.getCellCSSText(record, rowNum, colNum);
        }
    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SmartGWT - 如何检查 ListGridRecord 是展开还是折叠? - SmartGWT - how to check if ListGridRecord is expanded or collapsed? 如何将带有clickHandler的锚添加到GWT中的ListGridRecord - How to add Anchor with clickHandler to ListGridRecord in GWT 如何获得一个空白画布,我可以使用手写笔写 - how to get a blank canvas on which I can write using stylus 如何获得从网格单击的组件? - How can I get the component I clicked on from a grid? 如何从JList中的组件获取文本? - How can I get the text from a component in a JList? 如何将Android EditText组件的值作为整数获取? - How can I get the value of an Android EditText component as an integer? 如何从摆动组件获取类名称? - How can I get the Class name from a swing Component? 如何在 Tapestry 5 组件中获取父封装体的 clientId? - How can I get clientId of parent encloser in Tapestry 5 component? 如何从使用LinearGradientPaint绘制的画布中获取某个RGB值? - How can I get a certain RGB value from a canvas painted with LinearGradientPaint? 如何在Android中获取经度和纬度并将其传递给canvas类,以便我可以在位图上绘制 - How to get longitude and latitude in android and pass it on to a canvas class so i can draw on a bitmap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM