|
1 | 1 | /*! |
2 | | - * jQuery Bootgrid v1.1.1 - 09/24/2014 |
| 2 | + * jQuery Bootgrid v1.2.0 - 09/24/2014 |
3 | 3 | * Copyright (c) 2014 Rafael Staib (http://www.jquery-bootgrid.com) |
4 | 4 | * Licensed under MIT http://www.opensource.org/licenses/MIT |
5 | 5 | */ |
|
133 | 133 | } |
134 | 134 |
|
135 | 135 | // ensures that only the first order will be applied in case of multi sorting is disabled |
136 | | - if (!that.options.multiSort && column.order !== null) |
| 136 | + if (!that.options.multiSort && column.order != null) |
137 | 137 | { |
138 | 138 | sorted = true; |
139 | 139 | } |
|
751 | 751 | (sorting && sortOrder && sortOrder === "desc") ? css.iconDown : ""), |
752 | 752 | icon = tpl.icon.resolve(getParams.call(that, { iconCss: iconCss })), |
753 | 753 | align = column.headerAlign, |
754 | | - cssClass = (column.headerCssClass.length > 0) ? " " + column.headerCssClass : ""; |
| 754 | + cssClass = ((column.headerCssClass.length > 0) ? " " + column.headerCssClass : "") + |
| 755 | + ((that.options.highlightColumns && column.order != null) ? " " + that.options.css.active : ""); |
755 | 756 | html += tpl.headerCell.resolve(getParams.call(that, { |
756 | 757 | column: column, icon: icon, sortable: sorting && column.sortable && css.sortable || "", |
757 | 758 | css: ((align === "right") ? css.right : (align === "center") ? |
|
764 | 765 | // todo: create a own function for that piece of code |
765 | 766 | if (sorting) |
766 | 767 | { |
767 | | - var sortingSelector = getCssSelector(css.sortable), |
| 768 | + var activeSelector = getCssSelector(css.active), |
| 769 | + sortingSelector = getCssSelector(css.sortable), |
768 | 770 | iconSelector = getCssSelector(css.icon); |
769 | 771 | headerRow.off("click" + namespace, sortingSelector) |
770 | 772 | .on("click" + namespace, sortingSelector, function (e) |
771 | 773 | { |
772 | 774 | e.preventDefault(); |
773 | 775 | var $this = $(this), |
774 | 776 | columnId = $this.data("column-id") || $this.parents("th").first().data("column-id"), |
775 | | - sortOrder = that.sort[columnId], |
776 | | - icon = $this.find(iconSelector); |
| 777 | + sortOrder = that.sort[columnId]; |
777 | 778 |
|
778 | 779 | if (!that.options.multiSort) |
779 | 780 | { |
780 | | - $this.parents("tr").first().find(iconSelector).removeClass(css.iconDown + " " + css.iconUp); |
| 781 | + $this.parents("tr:first").find(iconSelector).removeClass(css.iconDown + " " + css.iconUp) |
| 782 | + .end().find(activeSelector).removeClass(css.active); |
781 | 783 | that.sort = {}; |
782 | 784 | } |
783 | 785 |
|
784 | 786 | if (sortOrder && sortOrder === "asc") |
785 | 787 | { |
786 | 788 | that.sort[columnId] = "desc"; |
787 | | - icon.removeClass(css.iconUp).addClass(css.iconDown); |
| 789 | + $this.parent().addClass(css.active).find(iconSelector) |
| 790 | + .removeClass(css.iconUp).addClass(css.iconDown); |
788 | 791 | } |
789 | 792 | else if (sortOrder && sortOrder === "desc") |
790 | 793 | { |
|
799 | 802 | } |
800 | 803 | } |
801 | 804 | that.sort = newSort; |
802 | | - icon.removeClass(css.iconDown); |
| 805 | + $this.parent().removeClass(css.active).find(iconSelector) |
| 806 | + .removeClass(css.iconDown); |
803 | 807 | } |
804 | 808 | else |
805 | 809 | { |
806 | 810 | that.sort[columnId] = "asc"; |
807 | | - icon.removeClass(css.iconDown).addClass(css.iconUp); |
| 811 | + $this.parent().addClass(css.active).find(iconSelector) |
| 812 | + .removeClass(css.iconDown).addClass(css.iconUp); |
808 | 813 | } |
809 | 814 | } |
810 | 815 | else |
811 | 816 | { |
812 | 817 | that.sort[columnId] = "asc"; |
813 | | - icon.addClass(css.iconUp); |
| 818 | + $this.parent().addClass(css.active).find(iconSelector) |
| 819 | + .addClass(css.iconUp); |
814 | 820 | } |
815 | 821 |
|
816 | 822 | sortRows.call(that); |
|
951 | 957 | this.header = null; |
952 | 958 | this.footer = null; |
953 | 959 | this.xqr = null; |
| 960 | + this.original = this.element.clone(); |
954 | 961 |
|
955 | 962 | // todo: implement cache |
956 | 963 | }; |
|
1021 | 1028 | **/ |
1022 | 1029 | keepSelection: false, |
1023 | 1030 |
|
| 1031 | + /** |
| 1032 | + * Defines whether the columns which are filtered or sorted should be highlighted or not. |
| 1033 | + * |
| 1034 | + * @property highlightColumns |
| 1035 | + * @type Boolean |
| 1036 | + * @default false |
| 1037 | + * @for defaults |
| 1038 | + * @since 1.2.0 |
| 1039 | + **/ |
| 1040 | + highlightColumns: false, |
| 1041 | + |
1024 | 1042 | highlightRows: false, // highlights new rows (find the page of the first new row) |
1025 | 1043 | sorting: true, |
1026 | 1044 | multiSort: false, |
|
1113 | 1131 | **/ |
1114 | 1132 | css: { |
1115 | 1133 | actions: "actions btn-group", // must be a unique class name or constellation of class names within the header and footer |
| 1134 | + |
| 1135 | + /** |
| 1136 | + * CSS class to highlight active parts like sorted or filtered columns. |
| 1137 | + * |
| 1138 | + * @property active |
| 1139 | + * @type String |
| 1140 | + * @default "active" |
| 1141 | + * @for css |
| 1142 | + * @since 1.2.0 |
| 1143 | + **/ |
| 1144 | + active: "active", |
| 1145 | + |
1116 | 1146 | center: "text-center", |
1117 | 1147 | columnHeaderAnchor: "column-header-anchor", // must be a unique class name or constellation of class names within the column header cell |
1118 | 1148 | columnHeaderText: "text", |
|
1234 | 1264 | { |
1235 | 1265 | if (this.options.ajax) |
1236 | 1266 | { |
1237 | | - // todo: implement ajax DELETE |
| 1267 | + // todo: implement ajax POST |
1238 | 1268 | } |
1239 | 1269 | else |
1240 | 1270 | { |
|
1298 | 1328 | { |
1299 | 1329 | this.footer.remove(); |
1300 | 1330 | } |
1301 | | - this.element.remove("tbody").off(namespace).removeData(namespace); |
| 1331 | + this.element.before(this.original).remove(); |
1302 | 1332 |
|
1303 | 1333 | return this; |
1304 | 1334 | }; |
|
0 commit comments