前台 js easyUI datagrid 杂记 验证(disable)
$("#car_id").droplist({
panelWidth:'450',
panelHeight:'auto',
idField : 'car_id',
textField : 'car_law_id',
mainTable:{tableName:'tcp_base_car_info',tableAlias:'u'},
joinTable:[
{tableName:'tcp_vehicle_oil_card',tableAlias:'o',joinType:'left join',joinKey:'o.org_id = u.org_id'}
],
columns : [[
{field:'car_law_id',columnAlias:'u',title: '车牌号' ,align:'center',width: 146},
{field:'car_model',columnAlias:'u',title: '车型',align:'center',width: 146},
{field:'org_id',columnAlias:'u',title: '部门id',align:'center',width: 146},
{field:'car_id',columnAlias:'u',title: '车id',align:'center',width: 100,hidden:'true'},
{field:'car_band',columnAlias:'u',title: '车辆品牌',align:'center',width: 100,hidden:'true'},
{field:'car_status',columnAlias:'u',title: '车辆状态',align:'center',width: 100,hidden:'true'},
{field:'use_fuel_per_100',columnAlias:'u',title: '油耗指标',align:'center',width: 60,hidden:'true'},
{field:'main_card_no',columnAlias:'o',title: '油卡号',align:'center',width: 60,hidden:'true'}
]],
onCheck: function (rowIndex, rowData){
$('#car_law_id').val(rowData.car_law_id);
$("#org_id").combogrid("setValue", rowData.org_id);
$("#car_type").combogrid("setValue", rowData.car_model);
$("#car_brand").combobox("setValue", rowData.car_band);
$("#car_status").combobox("setValue", rowData.car_status);
$("#fuel_quota").val(rowData.use_fuel_per_100);
oilCard = rowData.main_card_no;
fuel_quota = rowData.use_fuel_per_100;
},
});
1.获取datagrid列表这所显示的所有数据。
var rows = $("#datagridID").datagrid("getRows"); 这段代码是获取当前页的所有行。
---------------------------------------------------------------------------
2.loadData方法,这个方法有比较大的不同,首先它加载的本地数据,就是不会跟后台什么的有交互,它的使用方式是
$("#datagridID").datagrid("loadData", “total”:”30″,rows:[] );
easyui 中 datagrid 排序问题
当我们设置按照某列排序时,datagrid添加属性:sortName:排序的列,sortOder:'ASC'或'DESC',remoteSort:false,
其中remoteSort属性,默认为true,如果对本地数据排序必须设置为false
实现点击列表头可以排序还要再列的属性中添加 列的sortable属性
以下默认按照'gridName'升序排列
sortOrder: 'asc',
sortName: 'gridName',
remoteSort:false,
columns:[[
{field:'villageName',title:'村居名称',width:100,align:'center',sortable:'true'},
{field:'gridName',title:'网格名称',width:100,align:'center',sortable:'true'}]]
---------------------------------------------------------------------------------------------------------------
//快捷键保存方法
$(document).keyup(function (e) {
if (e.keyCode == 13 ) {
$('#tms_trans_goods_bill_detail').datagrid("endEdit",selectIndex);
calculate();
}
});
-----------------------------------------------------------------------------------------------
使用JS动态生成一串长度为32的流水号,以下方法可以实现
- <script>
- function randomString(len) {
- len = len || 32;
- var $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- var maxPos = $chars.length;
- var pwd = '';
- for (i = 0; i < len; i++) {
- //0~32的整数
- pwd += $chars.charAt(Math.floor(Math.random() * (maxPos+1)));
- }
- return pwd;
- }
- document.write(randomString(32));
- </script>
----------------------------------------------------------------------------------------------------------------------------------
前台验证
easyui form取消验证
$("#"+targetId).numberbox('disableValidation');
easyui form添加验证
$("#cust_mobile").validatebox('enableValidation');