Help with multi select

In CGridView, i want to catch selected rows and delete.




        $deleteUrl=$this->createUrl('notaFiscal/deleteMultiple');

        $this->widget('zii.widgets.jui.CJuiButton',

            array(

                'name'=>'button',

                'caption'=>'Delete Multiple',

                'onclick'=>

                'js:function()

                { 

                    var selectionIds = $.fn.yiiGridView.getSelection("ordem-servico-grid");

                    if (selectionIds.length!==0) {

                            $.ajax.({

                                    type: "POST",

                                    url: "' . $deleteUrl . '",

                                    data: {ids: selectionIds},

                                    dataType: "json",

                                    success: function() { $.fn.yiiGridView.updateGrid("ordem-servico-grid"); },

                            });

                    }

                    else

                    {

                        alert("nothing selected");

                    }

                    this.blur();

                    return false;

                }',

                'buttonType'=>'button',

            )

        );



If i click "delete multiple" with no selected rows alert("nothing selected") shows as expected.

But when one or more rows are selected the following error occurs:




Error: XML filter is applied to non-XML value (function (origSettings) {var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);var jsonp, status, data, callbackContext = origSettings && origSettings.context || s, type = s.type.toUpperCase();if (s.data && s.processData && typeof s.data !== "string") {s.data = jQuery.param(s.data, s.traditional);}if (s.dataType === "jsonp") {if (type === "GET") {if (!jsre.test(s.url)) {s.url += (rquery.test(s.url) ? "&" : "?") + (s.jsonp || "callback") + ("=?");}} else if (!s.data || !jsre.test(s.data)) {s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + ("=?");}s.dataType = "json";}if (s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url))) {jsonp = s.jsonpCallback || "jsonp" + jsc++;if (s.data) {s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");}s.url = s.url.replace(jsre, "=" + jsonp + "$1");s.dataType = "script";window[jsonp] = window[jsonp] || function (tmp) {data = tmp;success();complete();window[jsonp] = undefined;try {delete window[jsonp];} catch (e) {}if (head) {head.removeChild(script);}};}if (s.dataType === "script" && s.cache === null) {s.cache = false;}if (s.cache === false && type === "GET") {var ts = now();var ret = s.url.replace(rts, "$1_=" + ts + "$2");s.url = ret + (ret === s.url ? (rquery.test(s.url) ? "&" : "?") + ("_=" + ts) : "");}if (s.data && type === "GET") {s.url += (rquery.test(s.url) ? "&" : "?") + s.data;}if (s.global && !jQuery.active++) {jQuery.event.trigger("ajaxStart");}var parts = rurl.exec(s.url), remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);if (s.dataType === "script" && type === "GET" && remote) {var head = document.getElementsByTagName("head")[0] || document.documentElement;var script = document.createElement("script");script.src = s.url;if (s.scriptCharset) {script.charset = s.scriptCharset;}if (!jsonp) {var done = false;script.onload = script.onreadystatechange = function () {if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {done = true;success();complete();script.onload = script.onreadystatechange = null;if (head && script.parentNode) {head.removeChild(script);}}};}head.insertBefore(script, head.firstChild);return undefined;}var requestDone = false;var xhr = s.xhr();if (!xhr) {return;}if (s.username) {xhr.open(type, s.url, s.async, s.username, s.password);} else {xhr.open(type, s.url, s.async);}try {if (s.data || origSettings && origSettings.contentType) {xhr.setRequestHeader("Content-Type", s.contentType);}if (s.ifModified) {if (jQuery.lastModified[s.url]) {xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);}if (jQuery.etag[s.url]) {xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);}}if (!remote) {xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");}xhr.setRequestHeader("Accept", s.dataType && s.accepts[s.dataType] ? s.accepts[s.dataType] + ", */*" : s.accepts._default);} catch (e) {}if (s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false) {if (s.global && !--jQuery.active) {jQuery.event.trigger("ajaxStop");}xhr.abort();return false;}if (s.global) {trigger("ajaxSend", [xhr, s]);}var onreadystatechange = xhr.onreadystatechange = function (isTimeout) {if (!xhr || xhr.readyState === 0 || isTimeout === "abort") {if (!requestDone) {complete();}requestDone = true;if (xhr) {xhr.onreadystatechange = jQuery.noop;}} else if (!requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout")) {requestDone = true;xhr.onreadystatechange = jQuery.noop;status = isTimeout === "timeout" ? "timeout" : !jQuery.httpSuccess(xhr) ? "error" : s.ifModified && jQuery.httpNotModified(xhr, s.url) ? "notmodified" : "success";var errMsg;if (status === "success") {try {data = jQuery.httpData(xhr, s.dataType, s);} catch (err) {status = "parsererror";errMsg = err;}}if (status === "success" || status === "notmodified") {if (!jsonp) {success();}} else {jQuery.handleError(s, xhr, status, errMsg);}complete();if (isTimeout === "timeout") {xhr.abort();}if (s.async) {xhr = null;}}};try {var oldAbort = xhr.abort;xhr.abort = function () {if (xhr) {oldAbort.call(xhr);}onreadystatechange("abort");};} catch (e) {}if (s.async && s.timeout > 0) {setTimeout(function () {if (xhr && !requestDone) {onreadystatechange("timeout");}}, s.timeout);}try {xhr.send(type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null);} catch (e) {jQuery.handleError(s, xhr, null, e);complete();}if (!s.async) {onreadystatechange();}

function success() {if (s.success) {s.success.call(callbackContext, data, status, xhr);}if (s.global) {trigger("ajaxSuccess", [xhr, s]);}}




function complete() {if (s.complete) {s.complete.call(callbackContext, xhr, status);}if (s.global) {trigger("ajaxComplete", [xhr, s]);}if (s.global && !--jQuery.active) {jQuery.event.trigger("ajaxStop");}}




function trigger(type, args) {(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);}


return xhr;})

Source File: http://localhost/distopia/index.php?r=notaFiscal/view&id=2

Line: 184



What am I missing?

Thanks in advance

anyone?

Does this work?


  data: ({ids: selectionIds}),

/Tommy

In your ajax function you have mistake

delete extra point after "ajax" before "("

Thanks a lot, that was the problem… shame on me :rolleyes: