`
microjava
  • 浏览: 309950 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

aom中js的控制

    博客分类:
  • aom
阅读更多

日期控件只显示年月
<w:dateField id="date4" format="yyyy-MM     -dd" width="80" onblur="test();"/>

<w:script>
function test()
		    {
		  
		  		var mydate = document.getElementById('myform:date4').value;
		  		document.getElementById('myform:date4').value = mydate.substring(0,7);
		  
		  	}
</w:script>


js控制
<w:script>
        function test() {
          alert('1110: ' + password.disabled);
          alert('1111: ');
          alert('1111: ' + document.getElementById('form2:birthday_outer').disabled);
          
          document.getElementById('form2:sex').disabled = 'true';
          document.getElementById('form2:sex_outer').disabled = 'true';
          
          //隐藏下拉框和label
          //document.getElementById('form2:sex').style.display = 'none';
          //document.getElementById('form2:sex_outer').style.display = 'none';
          //document.getElementById('form2:sex_label').style.display = 'none';
          
          //document.getElementById('form2:birthday').disabled = true;
          
          document.getElementById('form2:birthday_label').disabled = 'true';
          document.getElementById('form2:birthday').style.display = 'none';
          document.getElementById('form2:birthday_outer').style.display = 'none';
          document.getElementById('form2:birthday_label').style.display = 'none';
          
          
          //birthday.el.dom.readOnly = true;
          birthday.el.dom.disabled = true;
          //birthday.el.dom.disabled = false;
          
          //只读和不可用
          password.el.dom.readOnly = true;
          password.el.dom.disabled = true;
          //不可用
          //password.setDisabled('true');
          
          //隐藏
          //password.setVisible(false);
        }
        </w:script>

<h:outputLabel id="sex_label" value="性别:"/>
<w:combo id="sex" value="male">
  <f:selectItem itemLabel="男" itemValue="male"/>
  <f:selectItem itemLabel="女" itemValue="female"/>
</w:combo>
<h:outputLabel id="birthday_label" value="生日:"/>
<w:dateField id="birthday" jsvar="birthday" value="1988-09-09"/>


转换器的使用
<script>
                //<![CDATA[
            function formatAlertType(v, m,r){
               if (v == 1) {
                   m.attr="style='color:#000000;'";
                   v = "提示";
                   //alert('hello');
                   //alert(r);
                   //alert(r.get('alertmsg'));
                   r.data.alertmsg = "测试改变其他列的值";
                   //alert(r.data.alertmsg);
                   
                   return v;
               } 
               else if (v == 2) {
                   m.attr="style='color:#0000ff;'";
                   v = "告警";
                   return v;
               }
               if (v == '3') {
                   m.attr="style='color:#0066ff;'";
                   v = "严重告警";
                   return v;
               }
               if (v == '4') {
                   m.attr="style='color:red;'";
                   v = "危险";
                   return v;
               }
               else {
                   m.attr="style='color:green'";
                   v = "其他";
               }
               return v;
            }
            function formatAreaid(v, m){
               if (v == 'hz') {
                   m.attr="style='color:red;'";
                   v = "惠州";
               } else {
                   m.attr="style='color:green'";
               }
               return v;
            }
            function formatMachid(v, m){
               if (v == 'ap1') {
                   m.attr="style='color:red;'";
                   v = "机器1";
               } 
               else {
                   m.attr="style='color:green'";
               }
               return v;
            }
            function formatAlertMsg(v, m,r){
            
               //alert(r.get('alerttype'));
               if(4 == r.get('alerttype')||6 == r.get('alerttype'))
               {
                 m.attr="style='color:red;'";
               }
               else {
                   m.attr="style='color:green'";
               }
               return v;
            }
            
            function formatHomepage(v) {
                return '<a href="' + v + '" target=_blank>' + v + '</a>';
            }
            function formatLogoUrl(v){
                return '<img src="' + v + '"/>';
            }
        //]]>
        
            //<![CDATA[
			function update(btn) {
			      if (atimer.scheduled && !atimer.cancelled) {
			        atimer.cancel();
			        btn.setText("开始实时告警监控");
			      } else {
			        atimer.schedule();
			        btn.setText("停止监控");
			      }
			      return false;
			}
			//]]>
        </script>

<w:dataGrid id="grid" paged="false" rows="20" height="450" width="1030">
            <w:outputColumn id="areaid" clientFormatter="formatAreaid" width="150" align="center" sortable="true" header="地市名" />
            <w:outputColumn id="machid" header="机器名" clientFormatter="formatMachid"/>
            <w:outputColumn id="alerttime" width="200" header="告警时间" />
            <w:outputColumn id="alerttype" header="告警类型" clientFormatter="formatAlertType"/>
            <w:outputColumn id="alertmsg" clientFormatter="formatAlertMsg" name="alertmsg" width="400" header="告警信息" />
</w:dataGrid>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics