Skip to content

Commit 3c1d36a

Browse files
author
hikki
committed
beta 线
1 parent ba13af6 commit 3c1d36a

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

component.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function componentLine(name,columns,data) {
139139
function selectTd(td,type,value,column) {
140140
switch (type) {
141141
case 'text':
142-
td.innerHTML = '<p style="text-overflow: ellipsis;overflow: hidden;display: block;white-space: nowrap;">'+value+'</p>';
142+
td.insertAdjacentHTML('afterbegin','<p style="text-overflow: ellipsis;overflow: hidden;display: block;white-space: nowrap;">'+value+'</p>');
143143
break;
144144
case 'input':
145145
let input = document.createElement('input');
@@ -158,7 +158,7 @@ function componentLine(name,columns,data) {
158158
td.appendChild(input);
159159
break;
160160
default:
161-
td.innerHTML = '<p style="text-overflow: ellipsis;overflow: hidden;display: block;white-space: nowrap;">'+value+'</p>';
161+
td.insertAdjacentHTML('afterbegin','<p style="text-overflow: ellipsis;overflow: hidden;display: block;white-space: nowrap;">'+value+'</p>');
162162
break;
163163
}
164164
}
@@ -186,6 +186,7 @@ function componentLine(name,columns,data) {
186186
}
187187
/*head foot*/
188188
var dom = document.getElementById(name);
189+
dom.style = 'overflow-x: auto;';
189190
var head = '<tr style="display:table;width:100%;table-layout:fixed;">';
190191
var foot = head;
191192
for (let column in columns){
@@ -195,19 +196,19 @@ function componentLine(name,columns,data) {
195196
if(columns[column].style){
196197
head += '<th style="'+columns[column].style+'">'+columns[column].name+'</th>';
197198
foot += '<th style="'+columns[column].style+'">' +
198-
'<input class="form-control" data-column="'+column+'" placeholder="添加:'+columns[column].name+'"/></th>';
199+
'<input class="form-control" data-column="'+column+'" placeholder=":'+columns[column].name+'"/></th>';
199200
continue;
200201
}
201202
head += '<th>'+columns[column].name+'</th>';
202203
foot += '<th>' +
203-
'<input class="form-control" data-column="'+column+'" placeholder="添加:'+columns[column].name+'"/></th>';
204+
'<input class="form-control" data-column="'+column+'" placeholder=":'+columns[column].name+'"/></th>';
204205
}
205206
head += '<th style="width: 30px"></th></tr>';
206207
foot += '<th style="width: 30px" class="JsonTableInsert"></th></tr>';
207208

208-
dom.insertAdjacentHTML('afterbegin','<style>#'+name+' tbody::-webkit-scrollbar { width: 0 !important }</style>' +
209-
'<table class="table table-striped table-bordered table-hover table-responsive">'+
210-
'<thead>'+head+'</thead></table>');
209+
dom.insertAdjacentHTML('afterbegin',`<style>#${name} tbody::-webkit-scrollbar { width: 0 !important }
210+
#${name} th,#${name} td{width: 100px}
211+
</style><table class="table table-striped table-bordered table-hover table-responsive"><thead>${head}</thead></table>`);
211212
/*hidden data container*/
212213
var dataInput = document.createElement('input');
213214
dataInput.setAttribute('name',name);
@@ -236,6 +237,11 @@ function componentLine(name,columns,data) {
236237
if(columns[column].style){
237238
td.style = columns[column].style;
238239
}
240+
}else if(columns[column].type !== 'text'){
241+
selectTd(td,columns[column].type,'',column);
242+
if(columns[column].style){
243+
td.style = columns[column].style;
244+
}
239245
}
240246
tr.setAttribute('data-key',key);
241247
tr.appendChild(td);

0 commit comments

Comments
 (0)