2013-12-10 39 views
2

我想對單行進行樣式設置,並避免爲我的行的每個單元格定義格式化程序。是否有相當於新的Dojo dgrid小部件的onStyleRow事件?Dojo dgrid:單行的風格如何?

謝謝。

+1

基於我能理解,似乎[onStyleRow](https://github.com/SitePen/dgrid/pull/561 )被濫用。這[post](https://github.com/SitePen/dgrid/issues/236)顯示了一個可能的解決方案,如果它滿足您的需求。 – medokr

+0

是的,這個評論:https://github.com/SitePen/dgrid/issues/236#issuecomment-11508012但不幸的是,這似乎並沒有在Dojo 1.9中工作 – maxxyme

+0

行了,代碼無法添加到我的Dgrid的定義,但在一個上下文中,就像在控制器中,我實際*創建*(與新的關鍵字)我的網格。 – maxxyme

回答

1

我結束了兩個不同的解決方案:

  1. 在控制器使用dgrid,基於在https://github.com/SitePen/dgrid/issues/236#issuecomment-11508012

    aspect.after(myDgrid, "renderRow", function(row, args) { 
         var data = args[0]; 
         if (data.unread) { 
          domClass.add(row, "unread"); 
         } 
         return row; 
        }); 
    
  2. 給出。在我自己的dgrid定義的解決辦法,但沒有「使用嚴格「 - 否則這將不起作用,你會得到這個錯誤:TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

    return declare("com.my.myDgrid", [ Grid, ... ], { 
        columns : [ { 
         ... 
        } ], 
    
        renderRow : function() { 
         var row = this.inherited(arguments); 
         var data = arguments[0]; 
         if (data.unread) { 
          domClass.add(row, "unread"); 
         } 
         return row; 
        } 
    }); 
    

的造型通過這個簡單的CSS規則完成:

#myDgridId .unread td { 
     font-weight: bold; 
    }