', this.header.fields.length));
+ }
+
+ if (!this.options.cardView && this.options.detailView) {
+ html.push('
',
+ '',
+ sprintf(' ', this.options.iconsPrefix, this.options.icons.detailOpen),
+ ' ',
+ ' ');
+ }
+
+ $.each(this.header.fields, function (j, field) {
+ var text = '',
+ value = getItemField(item, field, that.options.escape),
+ type = '',
+ cellStyle = {},
+ id_ = '',
+ class_ = that.header.classes[j],
+ data_ = '',
+ rowspan_ = '',
+ colspan_ = '',
+ title_ = '',
+ column = that.columns[j];
+
+ if (that.fromHtml && typeof value === 'undefined') {
+ return;
+ }
+
+ if (!column.visible) {
+ return;
+ }
+
+ if (that.options.cardView && !column.cardVisible) {
+ return;
+ }
+
+ style = sprintf('style="%s"', csses.concat(that.header.styles[j]).join('; '));
+
+ // handle td's id and class
+ if (item['_' + field + '_id']) {
+ id_ = sprintf(' id="%s"', item['_' + field + '_id']);
+ }
+ if (item['_' + field + '_class']) {
+ class_ = sprintf(' class="%s"', item['_' + field + '_class']);
+ }
+ if (item['_' + field + '_rowspan']) {
+ rowspan_ = sprintf(' rowspan="%s"', item['_' + field + '_rowspan']);
+ }
+ if (item['_' + field + '_colspan']) {
+ colspan_ = sprintf(' colspan="%s"', item['_' + field + '_colspan']);
+ }
+ if (item['_' + field + '_title']) {
+ title_ = sprintf(' title="%s"', item['_' + field + '_title']);
+ }
+ cellStyle = calculateObjectValue(that.header,
+ that.header.cellStyles[j], [value, item, i, field], cellStyle);
+ if (cellStyle.classes) {
+ class_ = sprintf(' class="%s"', cellStyle.classes);
+ }
+ if (cellStyle.css) {
+ var csses_ = [];
+ for (var key in cellStyle.css) {
+ csses_.push(key + ': ' + cellStyle.css[key]);
+ }
+ style = sprintf('style="%s"', csses_.concat(that.header.styles[j]).join('; '));
+ }
+
+ value = calculateObjectValue(column,
+ that.header.formatters[j], [value, item, i], value);
+
+ if (item['_' + field + '_data'] && !$.isEmptyObject(item['_' + field + '_data'])) {
+ $.each(item['_' + field + '_data'], function (k, v) {
+ // ignore data-index
+ if (k === 'index') {
+ return;
+ }
+ data_ += sprintf(' data-%s="%s"', k, v);
+ });
+ }
+
+ if (column.checkbox || column.radio) {
+ type = column.checkbox ? 'checkbox' : type;
+ type = column.radio ? 'radio' : type;
+
+ text = [sprintf(that.options.cardView ?
+ '
' : '
', column['class'] || ''),
+ ' ',
+ that.header.formatters[j] && typeof value === 'string' ? value : '',
+ that.options.cardView ? '' : ' '
+ ].join('');
+
+ item[that.header.stateField] = value === true || (value && value.checked);
+ } else {
+ value = typeof value === 'undefined' || value === null ?
+ that.options.undefinedText : value;
+
+ text = that.options.cardView ? ['
',
+ that.options.showHeader ? sprintf('%s ', style,
+ getPropertyFromOther(that.columns, 'field', 'title', field)) : '',
+ sprintf('%s ', value),
+ '
'
+ ].join('') : [sprintf('
',
+ id_, class_, style, data_, rowspan_, colspan_, title_),
+ value,
+ ' '
+ ].join('');
+
+ // Hide empty data on Card view when smartDisplay is set to true.
+ if (that.options.cardView && that.options.smartDisplay && value === '') {
+ // Should set a placeholder for event binding correct fieldIndex
+ text = '
';
+ }
+ }
+
+ html.push(text);
+ });
+
+ if (this.options.cardView) {
+ html.push('