MCPcopy
hub / github.com/layui/layui / renderGridEdit

Function renderGridEdit

src/modules/table.js:3158–3197  ·  view source on GitHub ↗
(othis, e)

Source from the content-addressed store, hash-verified

3156
3157 // 渲染单元格编辑状态
3158 var renderGridEdit = function (othis, e) {
3159 othis = $(othis);
3160
3161 if (othis.data('off')) return; // 不触发事件
3162
3163 var field = othis.data('field');
3164 var key = othis.data('key');
3165 var col = that.col(key);
3166 var index = othis.closest('tr').data('index');
3167 var data = table.cache[that.key][index];
3168 // var elemCell = othis.children(ELEM_CELL);
3169
3170 // 是否开启编辑
3171 // 若 edit 传入函数,则根据函数的返回结果判断是否开启编辑
3172 var editType =
3173 typeof col.edit === 'function' ? col.edit(data) : col.edit;
3174
3175 // 显示编辑表单
3176 if (editType) {
3177 var input = $(
3178 (function () {
3179 var inputElem =
3180 '<input class="layui-input ' + ELEM_EDIT + '" lay-unrow>';
3181 if (editType === 'textarea') {
3182 inputElem =
3183 '<textarea class="layui-input ' +
3184 ELEM_EDIT +
3185 '" lay-unrow></textarea>';
3186 }
3187 return inputElem;
3188 })()
3189 );
3190 input[0].value = (function (val) {
3191 return val === undefined || val === null ? '' : val;
3192 })(othis.data('content') || data[field]);
3193 othis.find('.' + ELEM_EDIT)[0] || othis.append(input);
3194 input.focus();
3195 e && layui.stope(e);
3196 }
3197 };
3198
3199 // 单元格编辑 - 输入框内容被改变的事件
3200 that.layBody

Callers 1

table.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected