[英]jqgrid with custom row colors
I´m using dynamic data我正在使用动态数据
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="1">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="2"></tr>
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="3">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="4"></tr>
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="5">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="6"></tr>
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="7">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="8"></tr>
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="9">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="10"></tr>
<tr class="ui-widget-content jqgrow ui-row-ltr" role="row" id="11">...</tr>
<tr class="ui-widget-content jqgrow ui-row-ltr myAltRowClass" role="row" id="12"></tr>
The rows are mark with id from 1 to 12.这些行用 1 到 12 的 id 标记。
How can i color the row with id=11 and id=12 with maybe red?我如何将 id=11 和 id=12 的行着色为红色?
This is a scoring board, and the two rows in the bottom marks that they will be sent down to lower premier league.这是一个计分板,底部的两行表示他们将被降级到下级联赛。
If you will always have a list of 12 teams in this table and want to highlight bottom two only then its easy to do via CSS.如果您将始终在此表中列出 12 个团队,并且只想突出显示底部的两个团队,那么通过 CSS 很容易做到。 Just create a rule like
只需创建一个规则
tr#11{ background-color:#fff100} tr#11{ 背景颜色:#fff100}
same for tr#12 tr#12 相同
However if you want it to be dynamic and want to have last two rows with relegate ID.但是,如果您希望它是动态的并且希望最后两行具有降级 ID。 Then you need to do following on server side or client side.
然后你需要在服务器端或客户端进行以下操作。
You can also use DOM to navigate to last tr item in table and keep one previous item in a variable as well then use both items and add a style attribute to them with background colour.您还可以使用 DOM 导航到表中的最后一个 tr 项目,并将前一个项目保留在变量中,然后使用这两个项目并使用背景颜色向它们添加样式属性。
There are several ways to achieve this.有几种方法可以实现这一点。 Depends on how you are getting your grid out and which way you feel comfortable as well as performance overheads.
取决于你如何让你的网格出来,你感觉舒服的方式以及性能开销。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.