工作总结

easy UI:

1.加载搜索部分的Combox的数据

 var LoadDownData = function() {
        $.ajax({
            type:'post',
            url:'@Url.Action("QuestionType","Question")',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            success: function(data) {
                $('#selectType').combobox({
                    valueField: 'id',
                    textField: 'text',
                    panelHeight: 400,
                    data: data
                });
            }
        });
    };

2.新增的时候数据需要给默认值

  function Append() {
        if (EndEditing()) {
            editButtonState = true;
            var myDate = new Date();
            var currentDate = myDate.getFullYear() + "-" + (myDate.getMonth() + 1) + "-" + myDate.getDate();

            $("#grid").datagrid('insertRow', { index: 0, row: { PROBLEM_TIME: currentDate, ANSWER_TIME: currentDate} }); //在这里给默认值,PROBLEM_TIME是Filed的名称,后面跟上值

            editIndex = 0;
            $("#grid").datagrid('selectRow', editIndex)
                .datagrid('beginEdit', editIndex);
        }
    }

3.行内编辑时Combox的数据提供

{
            field: 'TYPE',
            title: '类型',
            width: 100,
            align: 'left',
            formatter: function(value, row, index) {
                if (row.TYPE != "" && row.TYPE != null) {
                    return row.TYPE;
                }
                return "";
            },
            editor: {
                type: 'combobox',
                options: {
                    valueField: 'id',
                    textField: 'text',
                    data: null,//写到这里的话,直接写数据
                    url:'@Url.Action("QuestionType","Question")'//这里写个URL它自己会去请求
                }
            }
        }

4.获取某一个单元格的值

 var _jhmc = $('#grid').datagrid('getEditor', { index: editIndex, field: 'WELL_COMMON_NAME' });

对应的文档:

获取特定的编辑器,options参数有2个属性:
index:行索引。
field:字段名。 
示例:

// get the datebox editor and change its value
var ed = $('#dg').datagrid('getEditor', {index:1,field:'birthday'});
$(ed.target).datebox('setValue', '5/4/2012');

5.Easy UI目标对象转换为JQuery对象,使用.target(注:极少部分情况,还可能是DOM对象哦!)

$(ed.target).datebox('setValue', '5/4/2012');

6.JS获取URL参数

CommUtils.getQueryString = function (name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return r[2]; return null;
}

 7.JavaScript  concat方法

concat() 方法用于连接两个或多个数组。

该方法不会改变现有的数组,而仅仅会返回被连接数组的一个副本。

比如:数组a.concat(数组B),这样子数组a是不会变的,想让它改变需要:数组a=数组a.concat(数组B)

8.JS 过几秒再去继续往下执行

setTimeout(function(){},1000);//function里面写方法,后面的1000是毫秒。

9.监听回车事件

 //回车键处理
        $(document).keydown(function (event) {
            if (event.keyCode == 13) {//13是回车键
                //do somthingreturn false;//注意:必须要return false,因为页面中其他控件可能会监听回车键,这样子避免其他事件的触发
            }
        });

 

posted @ 2015-09-11 09:38  人生无赖  阅读(249)  评论(0编辑  收藏  举报