标签:
$.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; } } }); });
标签:
原文地址:http://www.cnblogs.com/bluestream/p/4792733.html