2013-12-11 40 views
0

我需要在DataTables.js數據表中每當它處於非活動狀態時突出顯示一行。我在我的剃刀中設置了一些代碼,用id的「非活動」來標記<tr>,並在我的CSS中設置了相應的背景顏色。但是,我不能得到任何東西,只是出現的原始風格。將動態樣式應用於數據錶行

CSS

/* 
* Table styles 
*/ 
table.pretty { 
    width: 100%; 
    clear: both; 
} 

table.pretty td#Inactive { 
    padding: 5px; 
    border: 1px solid #fff; 
    background-color: #FB9090; 
} 

table.pretty td, 
table.pretty th { 
    padding: 5px; 
    border: 1px solid #fff; 
} 

/* Header cells */ 
table.pretty thead th { 
    background: #6699FF; /* #66a9bd; */ 
    color: white; 
} 

/* Body cells */ 
table.pretty tbody th { 
    text-align: left; 
    background: black; /*#91c5d4; */ 
    color: white; 
} 

table.pretty tbody td { 
    background: white; /* #d5eaf0; */ 
} 

table.pretty tbody tr.odd td { 
    background: #e8eef4; /*#bcd9e1; */ 
} 

/* Footer cells */ 
table.pretty tfoot th { 
    background: #b0cc7f; 
    text-align: left; 
} 

table.pretty tfoot td { 
    background: #d7e1c5; 
    text-align: center; 
    font-weight: bold; 
} 

tr#Inactive 
{ 
    background-color: #FB9090; 
} 

HTML(渲染)

<tr id=Inactive style="vertical-align:top;"> 
    <td style="width:200px;"> 
     Name 
    </td> 
    <td> 
      <a href="http://insideapps.dev.com/periscope/Pages/Dist.aspx?statProducer=03432402" class="noLine" target="_blank">Fixed</a>    
    </td> 
    <td style="width:50px;"> 
        test 
     who&#39;s testing 
     I am 
     who&#39;s that eh? 
     me 
    </td> 
    <td style="width:50px;"> 
     109161 
    </td> 
    <td style="text-align:center"> 
      <a href=\\Prdhilfs03\l&amp;i-sales class="noLine"><img src="/Content/Images/attachment.png" height="20px;" width="20px;"/></a> 

    </td> 
    <td nowrap> 

    </td> 
    <td nowrap> 
    </td> 
    <td style="text-align:center; max-width: 50px;"> 
    </td> 
    <td> 
      <a href="/BankListMaster/Edit/1"><img src="/Content/Images/Pencil-icon.png" alt="edit" height="20px;" width="20px;"/></a><br />     

     <a href="/BankListMaster/Details/1"><img src="/Content/Images/Actions-view-list-text-icon.png" alt="details" height="20px;" width="20px;"/></a><br /> 

      <a href="/BankListMaster/Delete/1"><img src="/Content/Images/Actions-edit-delete-icon.png" alt="delete" height="20px;" width="20px;"/></a>     
    </td> 
</tr> 

jQuery的

 $("#thetable").dataTable({ 
      "sPaginationType": "full_numbers", 
      "iDisplayLength": 100, 
      "oLanguage": { 
       "sSearch": "Filter results:" 
      } 
     }); 
+0

一次只有一個是不活動的? – jameslafferty

回答

1

如果只有一個行inacti我一直在尋找:

tr#Inactive td 
{ 
    background-color: #FB9090; 
} 
+0

多行可同時處於非活動狀態 – NealR

+0

儘管如此,感謝您的幫助! – NealR

+0

對於多個不活動的行,您需要將類應用於非活動行,而不是id,並相應地更新css。您可能需要使用更具體的選擇器(例如''table tbody tr.inactive td''')來正確顯示它。只有一個元素被允許在頁面上擁有給定的ID。 – jameslafferty