Yii Framework Forum: Help with multi select - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Help with multi select Rate Topic: -----

#1 User is offline   betelgeuse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 12-January 09

Posted 28 October 2010 - 10:43 AM

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
a code snippet says more than a thousand words
0

#2 User is offline   betelgeuse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 12-January 09

Posted 28 October 2010 - 02:45 PM

anyone?
a code snippet says more than a thousand words
0

#3 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 28 October 2010 - 03:33 PM

View PostFlavio, on 28 October 2010 - 02:45 PM, said:

anyone?


Does this work?
  data: ({ids: selectionIds}),

/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#4 User is offline   rudenich 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 30-April 10
  • Location:Ukraine-Kramatorsk

Posted 28 October 2010 - 03:34 PM

In your ajax function you have mistake

Quote

$.ajax.({

delete extra point after "ajax" before "("
1

#5 User is offline   betelgeuse 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 99
  • Joined: 12-January 09

Posted 28 October 2010 - 04:32 PM

View Postrudenich, on 28 October 2010 - 03:34 PM, said:

In your ajax function you have mistake

delete extra point after "ajax" before "("


Thanks a lot, that was the problem.. shame on me :rolleyes:
a code snippet says more than a thousand words
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users