Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
small bug in grid.jqueryui.js and ui.multiselect.js
06/02/2010
00:33
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony!

In grid.jqueryui.js line 225 should be fixed. Lines 224-225 looks currently like

            var mopts = $.isFunction(opts.msel_opts) ? opts.msel_opts.call(self, opts) : opts.msel_opts;
            call(opts.msel, select, opts.msel_opts);

The line 225 should be fixed to at least following

            call(opts.msel, select, mopts);

Moreover in my tests with jquery-ui-1.8rc1 and jquery-1.4.js was mopts === undefined, which follows to errors inside of call(opts.msel, select, mopts). To fix the problem I had to make following changes:

In grid.jqueryui.js: the line 225 was repleced to the following 3 lines:

            if (mopts === undefined) { mopts = {} }
            if (mopts.dividerLocation === undefined) { mopts.dividerLocation = 0.6; }

            call(opts.msel, select, mopts);

(dividerLocation: 0.6 is the default value for dividerLocation, see line 300 of ui.multiselect.js).

Next change must be done inside of multiselect plugin. In ui.multiselect.js, in the function destroy the line 115 should be changed from

            $.widget.prototype.destroy.apply(this, arguments);

to

        if ($.widget.prototype.destroy !== undefined)
            $.widget.prototype.destroy.apply(this, arguments);

After the changes my project used jqGrid seems works with jquery-ui-1.8rc1 and jquery-1.4.1.js/jquery-1.4.js without any problems.

Best regards

Oleg

08/02/2010
12:14
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thanks Oleg. Forgot to fix this in the last moment, but let wait for the final jQueru UI 1.8.

My opinion is not  to cahnge the multiselect widget this way, but rather to set the fix in the grid file.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

16/02/2010
03:28
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony!

I’ll try to summarize me experience and suggestions to make columnChooser function from grid.jqueryui.js and ui.multiselect.js working with jquery-1.4.1 and jquery-ui-1.8rc1.

First of all, me previous suggestion to set mopts.dividerLocation to it’s default value was based on the exception inside of _init function of ui.multiselect.js in the lines 47-48:

    this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));

    this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));

The real problem is, that ui.multiselect.js define but don’t use $.ui.multiselect.defaults. So one receives "Invalid argument" Exception inside of jquery-1.4.1.js  (line 4456) during attempt to set width of element to NaNpx value.

One can fix the problem inside of grid.jqueryui.js. One can insert an additional line after the line number 238 in grid.jqueryui.js:

    var mopts = $.isFunction(opts.msel_opts) ? opts.msel_opts.call(self, opts) : opts.msel_opts;

    mopts = $.extend({}, $.ui.multiselect.defaults, mopts || {});

    call(opts.msel, select, mopts);

To fix problem with destructor of ui.multiselect I suggest make following change inside of destroy function:

       destroy: function() {

           this.element.show();

               this.container.remove();

 

               if ($.Widget === undefined)

                   $.widget.prototype.destroy.apply(this, arguments);

               else {

                   $.Widget.prototype.destroy.apply(this, arguments);

                   return this;

               }

       },

Old version looks like

       destroy: function() {

this.element.show();

this.container.remove();

 

$.widget.prototype.destroy.apply(this, arguments);

       },

The reason of such changes is a new  $.Widget introduced in jQuery 1.8 (see new jquery.ui.widget.js file from jquery-ui-1.8rc1). If you compare for example, jquery.ui.progressbar.js or from jquery-ui-1.8rc1 with ui.progressbar.js from jquery-ui-1.7.2 one can sees a differences.

Test whether $.Widget is defined I suggest to receive a code which works in both jquery-ui-1.7.2 and jquery-ui-1.8.

Best regards
Oleg

16/02/2010
19:33
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Tony!

Only short additional information. Just downloaded jQuery UI 1.8rc2 with jQuery 1.4.2 (from http://blog.jqueryui.com/2010/.....-ui-18rc2/) and tested everything here written one more time. Everything still works exactly as unter jQuery UI 1.8rc1 and jQuery 1.4.2.

Corresponds to just published the widget factory section of the Upgrade Guide to fix problem with $.ui.multiselect.defaults it is recomended to start

$.widget("ui.multiselect", {
    options: {
        sortable: true,
        searchable: true,
        animated: 'fast',
        show: 'slideDown',
        hide: 'slideUp',
        dividerLocation: 0.6,
        nodeComparator: function(node1, node2) {
            var text1 = node1.text(),
                    text2 = node2.text();
            return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1);
        }
    },
    _init: function() {

...

instead of calling

mopts = $.extend({}, $.ui.multiselect.defaults, mopts || {});

before call of call(opts.msel, select, mopts) inside of grid.jqueryui.js. Other changes from "Upgrade Guide" seems me not so important. For example, one recomends to rename _init to _create, but the code in jquery.ui.widget.js in jQuery UI 1.8rc2/rc2 looks like following:

_createWidget: function( options, element ) {

...

        this._create();
        this._init();
    },
    _create: function() {},
    _init: function() {},

    destroy: function() {
...

So both using of _create() or _init() will be working.

Different ways seems to me following to the same result. Currently we needs not make ui.multiselect.js perfect, but only make in working in both jQuery UI 1.8 and jQuery UI 1.7.

Best regards
Oleg

17/02/2010
11:15
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello Oleg,

Thank you very much for the recommendaions and investigations.

For now I do not have time to work on this.

Simply I recommend to make the changes in grid.jquery.ui.

Open the file and you will see at the beginning the following pice of code:

if ($.ui && $.ui.multiselect && $.ui.multiselect.prototype._setSelected) {
    var setSelected = $.ui.multiselect.prototype._setSelected;
    $.ui.multiselect.prototype._setSelected = function(item,selected) {
        var ret = setSelected.call(this,item,selected);
        if (selected && this.selectedList) {
            var elt = this.element;
            this.selectedList.find('li').each(function() {
                if ($(this).data('optionLink'))
                    $(this).data('optionLink').remove().appendTo(elt);
            });
        }
        return ret;
    }
}

this can be easy extended as

if ($.ui && $.ui.multiselect && ) {

if($.ui.multiselect.prototype._setSelected) {
    var setSelected = $.ui.multiselect.prototype._setSelected;
    $.ui.multiselect.prototype._setSelected = function(item,selected) {
        var ret = setSelected.call(this,item,selected);
        if (selected && this.selectedList) {
            var elt = this.element;
            this.selectedList.find('li').each(function() {
                if ($(this).data('optionLink'))
                    $(this).data('optionLink').remove().appendTo(elt);
            });
        }
        return ret;
    }

}

if($.ui.multiselect.prototype.destroy) {

// your code here

}
}

I recommend if possible to change the things in grid code instead and do not change multiselect.

At end of week I will play with this.

Best Regards and thanks again

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information