hahaorange1
2010-06-20 13:35
浏览 295
已采纳

Extjs Grid设置单行颜色后,没有效果

我写的一小段代码,生成一个Grid后,把第2行变成红色,结果没有效果,请您指正,多谢!
Ext.onReady(function(){

var cm = new Ext.grid.ColumnModel([
    {header: 'name', dataIndex: 'name'},
    {header: 'sex', dataInex: 'sex'},

]);

var PersonRecord = Ext.data.Record.create([
    {name: 'name', type: 'string'},
    {name: 'sex', type: 'int'},
    {name: 'color', type: 'string'}
]);

var data = [
    ['boy', 0, '#FBF8BF'],
    ['girl', 1, '#99CC66'],
    ['man', 0, '#F5C0C0'],
    ['woman', 1, '#FF0000']
];

var store = new Ext.data.Store({
    proxy: new Ext.data.MemoryProxy(data),
    reader: new Ext.data.ArrayReader({}, PersonRecord)
});
store.load();

var grid = new Ext.grid.GridPanel({
    store: store,
    cm: cm,
    autoHeight: true,
    renderTo: 'grid',

});
             我想把第2行设置为红色,结果运行后没有任何效果,请您指教!多谢!    
     grid.getView().getRow(1).style.backgroundColor='#FF0000';
     grid.getView().refresh(true);

});

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

6条回答 默认 最新

  • works001 2010-06-21 08:26
    已采纳
        <style type="text/css">
    

    .red-row{ background-color: red}

    <br> Ext.onReady(function(){<br> var PersonRecord = Ext.data.Record.create([<br> {name: &#39;name&#39;, type: &#39;string&#39;},<br> {name: &#39;sex&#39;, type: &#39;int&#39;},<br> {name: &#39;color&#39;, type: &#39;string&#39;}<br> ]);</p> <pre><code>var data = [ [&#39;boy&#39;, 0, &#39;#FBF8BF&#39;], [&#39;girl&#39;, 1, &#39;#99CC99&#39;], [&#39;man&#39;, 0, &#39;#F5C0C0&#39;], [&#39;woman&#39;, 1, &#39;#FFFFFF&#39;] ]; var store = new Ext.data.Store({ proxy: new Ext.data.MemoryProxy(data), reader: new Ext.data.ArrayReader({}, PersonRecord) }); store.load(); var grid = new Ext.grid.GridPanel({ store: store, columns: [ {header: &#39;name&#39;, dataIndex: &#39;name&#39;}, {header: &#39;sex&#39;, dataInex: &#39;sex&#39;} ], autoHeight: true, trackMouseOver:false, renderTo: &#39;grid&#39; }); Ext.get(&#39;change&#39;).on(&#39;click&#39;, function() { Ext.get(grid.getView().getRow(1)).radioClass(&quot;red-row&quot;) }); </code></pre> <p>});<br>





    评论
    解决 无用
    打赏 举报
查看更多回答(5条)

相关推荐 更多相似问题