1. 程式人生 > >ExtJS GridPanel根據條件改變字型顏色

ExtJS GridPanel根據條件改變字型顏色

1、在GridPanel中加入GridView

<View>

     <ext:GridView ID="GridView1" runat="server">

             <GetRowClass Fn="setRowBg" />

     </ext:GridView>

</View> 

2、加入js指令碼

<script language="javascript" type="text/javascript">

      function setRowBg(rd, ri, ro) {  

         var zhb,lj,xzh;

         zhb=rd.data.zhb;

         lj=rd.data.lj

         xzh=rd.data.xzh;  

         if (xzh=="正向")

         {

             if (zhb>lj)

             { 

                ro.tstyle = "color: #F57D02; ";  

             }

             else

             {

                ro.tstyle = "background-color:none;";  

             }

         } 

         if (xzh=="反向")

         {  

             if (zhb<lj)

             { 

                ro.tstyle = "color: #FFE37E; ";  

             }

             else

             {

                ro.tstyle = "background-color:none;";  

             }

         }

    }     

    </script>