• easyUi可编辑表格


    //表格展示
    
    $("#tt").datagrid({
        columns:[[
            {field:'itemid',title:'Item ID',80,sortable:true,editor:'text'},
            {field:'productid',title:'Product ID',80,sortable:true,editor:'text'},
            {field:'status',title:'Item Details',editor:'text'},
            {field:'listprice',title:'List Price',80,align:'right',sortable:true,
            editor:'text'
                },
            {field:'unitcost',title:'Unit Cost',80,align:'right',sortable:true,
            styler: function(value,row,index){
                    if (value < 12 || value > 12){
                        return 'color:red;';
                        // the function can return predefined css class and inline style
                        // return {class:'c1',style:'color:red'}
                    }
                }
            },
            {field:'attr1',title:'Attribute',100,formatter: function(value,row,index){
                  if (row.user){
                        return row.user.name;
                    } else {
                        return value;
                    }
                }},
        ]]
    });
        var editIndex = undefined; //全局变量
        var editField = undefined; //全局变量
    //数据网格编辑 $('#tt').datagrid({ onClickCell: function (index, field, value) { //每个文本框都可以编辑 if(endEditing()){ myonClickCell(index, field); } }, }); //自定义编辑 function myonClickCell(index,field){ editIndex = index; editField = field; $('#tt').datagrid('editCell', { index: index, field: field }); }
    
    //结束编辑
        function endEditing(){
        if (editIndex == undefined) { return true; }
                 if ($('#tt').datagrid('validateRow', 100)) {
                 console.log(111);
                    $('#tt').datagrid('endEdit', editIndex);
                     editIndex = undefined;
                     editField = undefined;
                     return true;
                } else {
                return false;
            }
        }
    //下面是单元格编辑方法
        $.extend($.fn.datagrid.methods, {
            editCell: function (jq, param) {
                // console.log(param){index: 3, field: "tb_zkje"};
                    return jq.each(function () {
                        var opts = $(this).datagrid('options');
                        var fields = $(this).datagrid('getColumnFields', true).concat($(this).datagrid('getColumnFields'));
                        for (var i = 0; i < fields.length; i++) {
                            var col = $(this).datagrid('getColumnOption', fields[i]);
                            col.editor1 = col.editor;
                            if (fields[i] != param.field) {
                                col.editor = null;
                            }
                        }
                        $(this).datagrid('beginEdit', param.index);
                        for (var i = 0; i < fields.length; i++) {
                            var col = $(this).datagrid('getColumnOption', fields[i]);
                            col.editor = col.editor1;
                        }
                    });
                }
         });
  • 相关阅读:
    Python爬虫实践 —— 4.好听音乐网轻音乐资源下载
    Python爬虫实践 —— urllib.request和requests
    Python爬虫实践 —— 3.利用爬虫提取返回值,模拟有道词典接口
    Python爬虫实践 —— 2.百度贴吧html文件爬取
    Python爬虫实践 —— 1.对反爬机制的认识
    用gcd库函数求最大公约数
    对结构体进行排序
    python菜鸟入门知识
    python安装及typora使用
    python基础一整型、bool、字符串
  • 原文地址:https://www.cnblogs.com/zoumin123/p/6347340.html
Copyright © 2020-2023  润新知