入门客AI创业平台(我带你入门,你带我飞行)
博文笔记

easyUI常用方法

创建时间:2018-01-14 投稿人: 浏览次数:207
HTML

<table id="tbList" striped="true" rownumbers="true" fix="true" fitcolumns="true" title="标题"
       idfield="ID" checkbox="true" url="@Url.Action("ListData")">
    <thead>
        <tr>
            <th field="ID" checkbox="true" width="30">
            </th>
            <th field="Name" width="200" align="center">
                名称
            </th> 
        </tr>
    </thead>
</table>

JS

$("#tbList").datagrid({ pagination: true });
$("#btnSearch").click(function () {//查询方法
    $("#tbList").datagrid("unselectAll");
    $("#tbList").datagrid({ queryParams: { SearchName: $("#SearchName").val()} });
});

1.冻结列

$("#tbList").datagrid({ pagination: true,
            frozenColumns: 
	    [[
            { field: "BId",checkbox:"true",width:30},
            { field: "BNo", title: "牌号", width: 100 },
            { field: "FNo", title: "班号", width: 100 }
           ]], 
       fitColumns:false //禁止自适应宽度、可以水平滚动
        });

2.table中td内容太长自动换行

添加属性 nowrap="false";

将nowrap: false这个属性设置在table的属性中,不要设置在字段的属性中,字段可以设置宽度,这样就可以做到当文字长度超过规定的宽度后自动换行了,false为换行/true为不换行。

3.常用事件

  1. $("#cc").combogrid({  
  2.         onSelect:function(index,row){  
  3.                           
  4.         },  
  5.         onChange:function(newVal ,oldVal){  
  6.             alert("newVal:" +newVal);  
  7.             alert("oldVal:" +oldVal);  
  8.             alert("getValue:" + $("#cc").combogrid("getValue"));  
  9.                           
  10.             var g = $("#cc").combogrid("grid"); // get datagrid object  
  11.         var r = g.datagrid("getSelected");  // get the selected row  
  12.         if(r ==null)  
  13.         alert("null");  
  14.         else  
  15.         alert("not null");  
  16.         }  
  17. });

4.校验表单完整性

//校验表单完整性

    function checkForm() {

        //获取需要校验的字段

        var code = $("#code").val();

        var name = $("#name").val();

        //校验字段是否为空

        if (name == "") {

            inputTips("请输入合同名称", "name", false);

            return false;

        }

        if (code == "") {

            inputTips("请输入合同编号", "code", false);

            return false;

        }

        return true;

    }









声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
  • 上一篇:没有了
  • 下一篇:没有了
未上传头像