Dushan
Dushan

Reputation: 215

Smart GWT List Grid - Setting a hilite to a list grid on record click

I'm trying to set a hilite inside the record click handler of the list grid. I have tired the following code,

My hilites are as follows,

 public static Hilite[] getWayBillSetHilites() {
        return new Hilite[]{
                new Hilite() {
                    {
                        setFieldNames("RECORD_VIEWED_STATUS");
                        setCriteria(new Criterion("RECORD_VIEWED_STATUS", OperatorId.EQUALS, "TRUE"));
                        setCssText(Constant.Css.TEXT_ITALIC_GRAY_32);
                        setTextColor("font-style:italic;color:#525252;");
                        setId("0");
                    }
                }
        };
    }

record click handler of the grid appears as follows,

     grid.addRecordClickHandler(new RecordClickHandler() {
        @Override
        public void onRecordClick(RecordClickEvent recordClickEvent) {
            //gridWayBillSetGrid.getHiliteState()
            //make RECORD_VIEWED_STATUS value "true"
            recordClickEvent.getRecord().setAttribute("RECORD_VIEWED_STATUS", true);
            gridWayBillSetGrid.enableHilite("0", true);

        }
    });

But when I click on the record, the styles are not showing up. Please be kind to advise on this.

Upvotes: 0

Views: 426

Answers (2)

Ehsan Khodarahmi
Ehsan Khodarahmi

Reputation: 4922

Try this one (override getCellCSSText method of ListGrid class):

ListGrid grid = new ListGrid(...){

            @Override
            protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {  
                if("true".equalsIgnoreCase(record.getAttribute("RECORD_VIEWED_STATUS"))){
                    return "font-style:italic;color:#525252;";
                }
                return super.getCellCSSText(record, rowNum, colNum);  
            }
        };

Upvotes: 1

claudiobosticco
claudiobosticco

Reputation: 413

I think it's the wrong use case for hilites. Use getCellCSSText instead.

Upvotes: 1

Related Questions