dojox.grid.DataGrid - onStyleRow needs update? (dojo 1.2.0)

女生的网名这么多〃 提交于 2019-12-22 00:42:52

问题


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.


回答1:


inRow.customStyles = "backgrund-color: #FFCC00";

You seem to have spelled background wrong.




回答2:


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.



来源:https://stackoverflow.com/questions/3985401/dojox-grid-datagrid-onstylerow-needs-update-dojo-1-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!