dojox.grid.DataGrid - onStyleRow needs update? (do

2019-04-15 15:45发布

we are using a dojox.grid.DataGrid in a jsp.

<script type="dojo/method" event="onStyleRow" args="inRow">
    var grid = dijit.byId("someID");
    var item = grid.getItem(inRow.index);
    if(item != undefined) {
        if(item.someAttribute == "1") {
            inRow.customClasses = "dojoxGridMYRow";
        } else {
            inRow.customClasses = "dojoxGridRow";
        }
    }     
    if(aBoolean) {
        inRow.customStyles = "backgrund-color: #FFCC00";
    }
    //dojox.grid.DataGrid.prototype.onStyleRow.apply(this, arguments);
    //grid.focus.styleRow(inRow);
    //grid.edit.styleRow(inRow);        
</script>

The first commented line is to get normal behaviour when clicking a row. But it wont change anything until a grid.update() is called, which is not nice, reloading many rows. Its like a flickering. The strange is, if the mouse goes over the changed rows it changes the background color(if no update was called). So it must be possible without a update. Calling updateRow or renderRow oder something like this will cause a infinite loop.

Can anyone help me? :/

Edit: I also tried to copy the behaviour of onStyleRow(cause the selected row is directly marked red), but it makes nothing else than setting customClasses and call this.focus.styleRow(inRow) and this.edit.styleRow(inRow). adding these lines to my function does also take no effect.

2条回答
仙女界的扛把子
2楼-- · 2019-04-15 16:16

For custom classes you probably want to append your class (with a space in front of it) rather than overriding the row's class. Replacing the classes will screw up the default CSS. Unless that's what you want...

inRow.customClasses += "dojoxGridMYRow";

And yes, you want this at the end:

dojox.grid.DataGrid.prototype.onStyleRow.apply(this, arguments);

I haven't see your issue, but I'm creating my grid programatically and using Dojo 1.7, so our environments are pretty different.

查看更多
Bombasti
3楼-- · 2019-04-15 16:35
inRow.customStyles = "backgrund-color: #FFCC00";

You seem to have spelled background wrong.

查看更多
登录 后发表回答