|
357 | 357 | // save td's id and class
|
358 | 358 | row['_' + field + '_id'] = $(this).attr('id');
|
359 | 359 | row['_' + field + '_class'] = $(this).attr('class');
|
360 |
| - row['_' + field + '_data_value'] = $(this).attr('data-value'); |
| 360 | + row['_' + field + '_data'] = $(this).data(); |
361 | 361 | });
|
362 | 362 | data.push(row);
|
363 | 363 | });
|
|
497 | 497 |
|
498 | 498 | if (index !== -1) {
|
499 | 499 | this.data.sort(function (a, b) {
|
500 |
| - var aa = a['_' + name + '_data_value'] || a[name], |
501 |
| - bb = b['_' + name + '_data_value'] || b[name], |
| 500 | + var aa = a[name], |
| 501 | + bb = b[name], |
502 | 502 | value = calculateObjectValue(that.header, that.header.sorters[index], [aa, bb]);
|
503 | 503 |
|
504 | 504 | if (value !== undefined) {
|
|
1030 | 1030 | cellStyle = {},
|
1031 | 1031 | id_ = '',
|
1032 | 1032 | class_ = that.header.classes[j],
|
| 1033 | + data_ = '', |
1033 | 1034 | column = that.options.columns[getFieldIndex(that.options.columns, field)];
|
1034 | 1035 |
|
1035 | 1036 | style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
|
|
1044 | 1045 | if (item['_' + field + '_class']) {
|
1045 | 1046 | class_ = sprintf(' class="%s"', item['_' + field + '_class']);
|
1046 | 1047 | }
|
1047 |
| - if (item['_' + field + '_data_value']) { |
1048 |
| - class_ = sprintf(' data-value="%s"', item['_' + field + '_data_value']); |
1049 |
| - } |
1050 | 1048 | cellStyle = calculateObjectValue(that.header,
|
1051 | 1049 | that.header.cellStyles[j], [value, item, i], cellStyle);
|
1052 | 1050 | if (cellStyle.classes) {
|
|
1060 | 1058 | style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; '));
|
1061 | 1059 | }
|
1062 | 1060 |
|
| 1061 | + if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) { |
| 1062 | + $.each(item['_' + field + '_data'], function (k, v) { |
| 1063 | + // ignore data-index |
| 1064 | + if (k === 'index') { |
| 1065 | + return; |
| 1066 | + } |
| 1067 | + data_ += sprintf(' data-%s="%s"', k, v); |
| 1068 | + }); |
| 1069 | + } |
| 1070 | + |
1063 | 1071 | if (column.checkbox || column.radio) {
|
1064 | 1072 | type = column.checkbox ? 'checkbox' : type;
|
1065 | 1073 | type = column.radio ? 'radio' : type;
|
|
1087 | 1095 | getPropertyFromOther(that.options.columns, 'field', 'title', field)) : '',
|
1088 | 1096 | sprintf('<span class="value">%s</span>', value),
|
1089 | 1097 | '</div>'].join('') :
|
1090 |
| - [sprintf('<td%s %s %s>', id_, class_, style), |
| 1098 | + [sprintf('<td%s %s %s %s>', id_, class_, style, data_), |
1091 | 1099 | value,
|
1092 | 1100 | '</td>'].join('');
|
1093 | 1101 |
|
|
0 commit comments