前端小知识集合

来源:互联网 发布:测声音频率软件 编辑:程序博客网 时间:2024/05/22 00:13

jsp中:
<%--日期选择框,日期区间,editable 输入框是否可编辑--%>
<input id="createTimeStart" name="createTimeStart" class="easyui-datebox" data-options="editable:false"> 
- <input id="createTimeEnd" name="createTimeEnd" class="easyui-datebox" data-options="editable:false">

<%--分隔横线--%>
<div class="datagrid-toolbar"></div>

<%--分隔竖线--%>
<div class="datagrid-btn-separator" />

<%--easyUi中combobox的禁用和启用--%>
$('#combobox类型的输入框的Id').combobox('enable');   //可用 
$('#combobox类型的输入框的Id').combobox({disabled:false});   //没有效果(可以打开下拉,但是不能选择)
$('#combobox类型的输入框的Id').combobox('disable');   //不可用(有效)
$('#combobox类型的输入框的Id').combobox({disabled:true});   //不可用(有效)
$('#combobox类型的输入框的Id').combobox('clear');   //清除 combobox 值.
$('#combobox类型的输入框的Id').combobox('setValues', '001'); //设置 combobox 值.

<%--重置表单--%>
document.getElementById("form的id").reset();

<%--input输入框设置长度无效或者跨列无效--%>
<tr>
  <td align=right width="100px">备注:</td>
  <td align=left colspan="5">
  <input class="easyui-textbox" id="remarkBatchUpdate" name="remarkBatchUpdate"style="width:665px;" maxlength=100/>
  </td>
</tr>

//除了要用colspan跨列外,还要用style="width:665px;",否则:
//1.只用colspan,会导致输入框显示的长度不变,如下图:

 


//2.只用style="width:665px;",会导致表格的第二列很长,然后格式乱掉,如下图:

 

 

 

 

<%--input输入框设置输入内容长度无效--%>
maxlength=100;//限制输入内容长度无效时,使用data-options="multiline:true,validType:'length[0,350]'"进行一个校验提醒

<%--表格横向滚动条设置--%>
<div class="jqGrid_wrapper">

//设置class为autoWidth,自动适应浏览器窗口的调整,否则,表格的大小将不随浏览器窗口大小而改变,导致有些列无法显示
   <table id="vehicleBillTable" class="autoWidth"></table>
<div id="pager"></div>

 

 

<input type="hidden" id="inputIdDR" name="inputId">

 


<%--easyui输入框的非空及格式校验--%>
<input class="easyui-numberbox" id="feeBridgeAdd" name="feeBridgeAdd" style="width:150px;"
     data-options="required:true, precision: 2, max:99999999.99, min:0.00"/>
//easyui-numberbox 必须是数字
//data-options 用于描述需要校验的项
//required:true 非空
//precision 精度

<%--easyui输入框的id和name的区别--%>
<input type="hidden" id="inputIdDR" name="inputId">
说明:id用于js中获取输入框的值;
   name为java后台或者说request中获取变量的名称;
   所以二者写成一样时,前端和后台不会出现参数不对的情况
  
  

js中:
var config = {
url:App.contextPath + '',//路径
autowidth: true,//作用与jsp中的//作用与jsp中的class="autoWidth"一样,此行可省略
//设置为true时,列会按长度比例缩放,无法出现滚动条,并且列中的数据会展示不全

shrinkToFit: false,
colNames: ['操作'],//列名
colModel: [{name: 'option', index: 'option', align: 'center', width: 80, sortable: false, formatter : operate},],//数据
rowNum : 15,//每页显示数量
rowList : [ 15, 30, 50 ],//每页可选显示数量
pager : '#pager',
sortname:'Report_Dttm',
sortorder:'desc',

//分页
jsonReader : {
page : "page",//第几页
total : "total",//共几页
records : "records",//总共要显示的数量
root : "rows",要显示的内容
repeatitems : false
}
};
jQuery("#table").jqGrid($.extend(JQGRID_BASE_CONFIG, config));

<%--修改tomcat默认编码方式--%>
找到tomcat下的conf/server.xml文件中的如下代码:   
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
这段代码规定了Tomcat监听HTTP请求的端口号等信息。
可以在这里添加一个属性:URIEncoding,将该属性值设置为UTF-8,即可让Tomcat(默认ISO-8859-1编码)以UTF-8的编码处理get请求。
修改完成后:
<Connector port="8080"  protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />

<%--JavaScript中==和===的区别--%>
假设给定 x=1:
运算符  描述  例子
==  等于              x==8 为 false
===  全等(值和类型)  x===1 为 true;x==="1" 为 false

<%--去掉jqgrid的复选框--%>
multiselect: false,//去掉jqgrid的复选框

if (!$('#formId').form('validate')) {//表单校验,easyui自带
showMessageAlter('提示', '数据格式有误,请正确填写!');
return;
}

/**获取当前日的前一天日期*/
function getYesterday(){
var now = new Date(new Date() - 24 * 3600 * 1000);
var year = now.getFullYear();
var month = now.getMonth() + 1 < 10 ? "0" + (now.getMonth() + 1): now.getMonth() + 1;
var day = now.getDate() < 10 ? "0" + now.getDate(): now.getDate();
var nowStr = year + "-" + month + "-" + day;
return nowStr;
}

 

0 0
原创粉丝点击