From dcf5e85818f8da3cd4ab84131b90693beaa8f835 Mon Sep 17 00:00:00 2001 From: Ben Davis Date: Wed, 29 Jul 2015 10:22:43 -0400 Subject: [PATCH] Added a check to see if there were no items. If there are no items it will not insert the extra multi select row and will not run multi select functions attached to it. Added support for actions as well if there are no items 1436 --- js/repeater-list.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/js/repeater-list.js b/js/repeater-list.js index 54127f4aa..1df5db21a 100755 --- a/js/repeater-list.js +++ b/js/repeater-list.js @@ -427,6 +427,7 @@ this.list_sortDirection = null; this.list_sortProperty = null; this.list_actions_width = (this.viewOptions.list_actions.width !== undefined) ? this.viewOptions.list_actions.width : 37; + this.list_noItems = false; callback(); }, resize: function () { @@ -481,16 +482,16 @@ after: function(){ var $sorted; - if (this.viewOptions.list_frozenColumns || this.viewOptions.list_selectable === 'multi') { + if ((this.viewOptions.list_frozenColumns || this.viewOptions.list_selectable === 'multi') && !this.list_noItems) { this.list_setFrozenColumns(); } - if (this.viewOptions.list_actions) { + if (this.viewOptions.list_actions && !this.list_noItems) { this.list_createItemActions(); this.list_sizeActionsTable(); } - if (this.viewOptions.list_frozenColumns || this.viewOptions.list_actions || this.viewOptions.list_selectable === 'multi') { + if ((this.viewOptions.list_frozenColumns || this.viewOptions.list_actions || this.viewOptions.list_selectable === 'multi') && !this.list_noItems) { this.list_positionColumns(); this.list_frozenOptionsInitialize(); } @@ -739,7 +740,12 @@ $table.append($tbody); } - if (data.items && data.items.length < 1) { + if (typeof data.error === 'string' && data.error.length > 0) { + $empty = $(''); + $empty.find('td').append(data.error); + $tbody.append($empty); + } + else if (data.items && data.items.length < 1) { $empty = $(''); $empty.find('td').append(this.viewOptions.list_noItemsHTML); $tbody.append($empty); @@ -777,7 +783,11 @@ if (this.list_firstRender || differentColumns(this.list_columns, columns) || $thead.length === 0) { $thead.remove(); - if (this.viewOptions.list_selectable === 'multi') { + if (data.count < 1) { + this.list_noItems = true; + } + + if (this.viewOptions.list_selectable === 'multi' && !this.list_noItems) { var checkboxColumn = { label: 'c', property: '@_CHECKBOX_@', @@ -790,7 +800,7 @@ this.list_firstRender = false; this.$loader.removeClass('noHeader'); - if (this.viewOptions.list_actions){ + if (this.viewOptions.list_actions && !this.list_noItems){ var actionsColumn = { label: this.viewOptions.list_actions.label || 'a', property: '@_ACTIONS_@', @@ -808,7 +818,7 @@ } $table.prepend($thead); - if (this.viewOptions.list_selectable === 'multi') { + if (this.viewOptions.list_selectable === 'multi' && !this.list_noItems) { //after checkbox column is created need to get width of checkbox column from //its css class var checkboxWidth = this.$element.find('.repeater-list-wrapper .header-checkbox').outerWidth();