Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap table 双击编辑时报错 #7

Open
guofude240913766 opened this issue Sep 5, 2019 · 0 comments
Open

bootstrap table 双击编辑时报错 #7

guofude240913766 opened this issue Sep 5, 2019 · 0 comments

Comments

@guofude240913766
Copy link

function queryUserList() {

    var options = {
        url: prefix + "/list",
        createUrl: prefix + "/add",
        updateUrl: prefix + "/edit/{id}",
        removeUrl: prefix + "/remove",
        exportUrl: prefix + "/export",
        modalName: "监控-字典对应",
        showExport: false,
        pagination: false,
        sortName: 'srot',
		sortOrder: 'asc',
        striped: true,
        showRefresh: false,
        uniqueId:"id",
        //onDblClickCell: onDblClickCell,
        onDblClickCell: onDblClickCell,

        columns: [{
            checkbox: false
        },
            {
                field : 'id',
                title : '',
                visible: false
            },
            {
                field : 'xmmc',
                title : '项目名称',
                sortable: true
            },
            {
                field : 'xmbm',
                title : '项目编码',
                sortable: true
            },
            {
                field : 'zdmc',
                title : '字段名称',
                sortable: true
            },
            {
                field : 'zdbm',
                title : '字典编码',
                sortable: true
            },
            {
                field : 'dyzdmc',
                title : '对应字段名称',
                sortable: true
            },
            {
                field : 'dyzdbm',
                title : '对应字段编码',
                sortable: true
            },
            {
                title: '操作',
                align: 'center',
                formatter: function(value, row, index) {
                    var actions = [];
                    // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                    // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
					var aStr1 = "<a onclick='syncClick(" + index + "," + row.id +")'><i class=\"fa fa-edit\"></i>同步</a>&nbsp;&nbsp;";
					var aStr = "<a onclick='addDy(" + index + "," + row.id +")'>新增对应关系</a>&nbsp;&nbsp;";
                    var aStr2="";
                    if(row.sfxzdygx!='1'){
                        var aStr2 = "<a onclick='del(" + index + "," + row.id +")' shiro:hasPermission=\"system:tEhrJkZddy:remove\">删除</a>"
					}
					//actions.push('<a onclick="addDy(\'' + tEhrJkMain, '\' + \'' + row.id + '\')">新增对应关系</a>')
					actions.push(aStr1);
					actions.push(aStr);
					actions.push(aStr2);
                    return actions.join('');
                }
            }
            ]
    };
    $.table.init(options);
}

function onDblClickCell(field, value, row, $element){
$.operate.edit(row.id);
}

/**
 * @param {点击列的 field 名称} field
 * @param {点击列的 value 值} value
 * @param {点击列的整行数据} row
 * @param {td 元素} $element
 */
function onDblClickCell(field, value, row, $element) {
    if(field == 'dyzdmc' || field == 'dyzdbm') {
        $element.attr('contenteditable', true);
        $element.blur(function () {
            var index = $element.parent().data('index');
            var tdValue = $element.html();

            saveData(index, field, tdValue, row);
        })
    }else{
        $.modal.alertError('只能修改对应字段名称和对应字段编码');
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant