码迷,mamicode.com
首页 > 其他好文 > 详细

EasyUI单击行数据时动态编写editor

时间:2015-09-08 21:33:20      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

    $.extend($.fn.treegrid.methods, {
            addEditor: function (jq, param) {
                if (param instanceof Array) {
                    $.each(param, function (index, item) {
                        var e = $(jq).treegrid(‘getColumnOption‘, item.field);
                        e.editor = item.editor;
                    });
                } else {
                    var e = $(jq).treegrid(‘getColumnOption‘, param.field);
                    e.editor = param.editor;
                }
            },
            removeEditor: function (jq, param) {
                if (param instanceof Array) {
                    $.each(param, function (index, item) {
                        var e = $(jq).treegrid(‘getColumnOption‘, item);
                        e.editor = {};
                    });
                } else {
                    var e = $(jq).treegrid(‘getColumnOption‘, param);
                    e.editor = {};
                }
            }
        });

//添加相关事件

$(function () {
            var lastIndex;
            $(‘#tg‘).treegrid({
                //行单击事件
                onClickRow: function (row) {
                    var editType = row.editType;
                    if (editType == edittext)                   //当属于Text类型是执行的语句
                    {
                        $("#tg").treegrid(‘addEditor‘, {
                            field: ‘value‘,
                            editor: {
                                type: ‘text‘,
                                options: {
                                    required: true
                                }
                            }
                        });
                        if (lastIndex != row.id) {
                            $(‘#tg‘).treegrid(‘endEdit‘, lastIndex);
                            $(‘#tg‘).treegrid(‘beginEdit‘, row.id);
                        }
                        else {
                            $(‘#tg‘).treegrid(‘beginEdit‘, row.id);
                        }
                        lastIndex = row.id;
                    }
                    else if (editType == editcombox)//当属于combobox类型是执行的语句
                    {
                        var editorValueID = row.editTypeValue;
                        alert(editorValueID);
                        $("#tg").treegrid(‘addEditor‘, {
                            field: ‘value‘,
                            editor: {
                               
                                type: ‘combobox‘,
                                options: {
                                    url: ‘Ajax/ServicesHandler.ashx?actionName=GetComboboxValue&editorValueID=‘ + editorValueID,
                                    valueField: ‘EdidValue‘,
                                    textField: ‘EdidValue‘,
                                    required: true
                                }
                            }
                        });
                        if (lastIndex != row.id) {
                            $(‘#tg‘).treegrid(‘endEdit‘, lastIndex);
                            $(‘#tg‘).treegrid(‘beginEdit‘, row.id);
                        }
                        else {
                            $(‘#tg‘).treegrid(‘beginEdit‘, row.id);
                        }
                        lastIndex = row.id;

                    }
                    
                }

            });
        });

 

EasyUI单击行数据时动态编写editor

标签:

原文地址:http://www.cnblogs.com/bluestream/p/4792733.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!