|
116 | 116 | this.options.onRefresh = window[onRefresh];
|
117 | 117 |
|
118 | 118 | // TODO: should we do this later on so we handle dynamically added buttons?
|
119 |
| - this.$element.find("[data-griddly-toggle=modal][href*='_griddlyIds']").each(function () |
| 119 | + this.$element.find("[data-append-rowids-to-url]").each(function () |
120 | 120 | {
|
121 | 121 | $(this).data("griddly-href-template", $(this).attr("href"));
|
122 | 122 | });
|
|
285 | 285 |
|
286 | 286 | var onRowChange = $.proxy(function (event)
|
287 | 287 | {
|
288 |
| - var ids = this.getSelected(); |
289 |
| - |
290 |
| - if (ids.length) |
291 |
| - ids = ids.join(","); |
292 |
| - else |
293 |
| - ids = ""; |
| 288 | + this.setSelectedCount(); |
294 | 289 |
|
295 |
| - this.$element.find("[data-griddly-toggle=modal]").each(function () |
| 290 | + this.$element.find("[data-append-rowids-to-url]").each(function () |
296 | 291 | {
|
297 | 292 | var template = $(this).data("griddly-href-template");
|
298 | 293 |
|
299 | 294 | if (template)
|
300 |
| - $(this).attr("href", template.replace(/_griddlyIds/g, ids)); |
301 |
| - }); |
| 295 | + { |
| 296 | + var selection = this.getSelected($(this).data["rowids"]); |
| 297 | + var query = []; |
| 298 | + for (var k in selection) |
| 299 | + { |
| 300 | + query[query.length] = k + "=" + selection[k].join(","); |
| 301 | + } |
302 | 302 |
|
303 |
| - this.setSelectedCount(); |
| 303 | + $(this).attr("href", template + (template.indexOf("?") > -1 ? "&" : "?") + query.join("&")); |
| 304 | + } |
| 305 | + }); |
304 | 306 | }, this);
|
305 | 307 |
|
306 | 308 | var setRowSelect = $.proxy(function ($checkbox)
|
|
820 | 822 |
|
821 | 823 | getSelected: function(arrayIdNames)
|
822 | 824 | {
|
| 825 | + if (arrayIdNames === "all") |
| 826 | + return this.options.selectedRows; |
| 827 | + |
823 | 828 | if (!arrayIdNames)
|
824 | 829 | arrayIdNames = this.options.defaultRowIds;
|
825 | 830 | else if (typeof arrayIdNames === "string")
|
826 | 831 | arrayIdNames = [ arrayIdNames ];
|
827 | 832 |
|
828 |
| - var result = {} |
| 833 | + var result = {}; |
829 | 834 | for (var name in arrayIdNames)
|
830 | 835 | result[arrayIdNames[name]] = $.map(this.options.selectedRows, function (x) { return x[arrayIdNames[name]] });
|
831 | 836 |
|
|
1009 | 1014 | if (token.length)
|
1010 | 1015 | inputs += '<input type="hidden" name="' + token.attr("name") + '" value="' + token.val() + '" />';
|
1011 | 1016 |
|
1012 |
| - $.each(selection, function () { |
1013 |
| - $.each(this, function () { |
1014 |
| - inputs += "<input name=\"ids\" value=\"" + this + "\" />"; |
| 1017 | + for (var idname in selection) |
| 1018 | + { |
| 1019 | + $.each(selection[idname], function () { |
| 1020 | + inputs += "<input name=\"" + idname + "\" value=\"" + this + "\" />"; |
1015 | 1021 | });
|
1016 |
| - }); |
| 1022 | + } |
1017 | 1023 |
|
1018 | 1024 | $("<form action=\"" + url + "\" method=\"post\">" + inputs + "</form>")
|
1019 | 1025 | .appendTo("body").submit().remove();
|
|
0 commit comments