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_Related Related Topics sp_TopicIcon
some bugs in new code from github (grid.base.js, grid.filter.js, grid.common.js and grid.formedit.js)
Tags: filtering
20/03/2011
02:15
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hello Tony!

I tried to localize one problem in the new grid.filter.js module and fund many bugs in different modules:

1) In the new vesrion of emptyRows() there are the third boolean parameter locdata. If it is set to true, the local data will be deleted. The problem is that in the addJSONData() which will be called for example on sorting of grid having local data in the line 1188 will be used emptyRows(t,false, true). So any grid having local data can make sorting only once. At the next sorting the empty grid will be shown. I suppose that the last parameter should probably really used as true in some situation, but first of all the code could be fixed to the emptyRows(t,false, false):

if(data) {
    if(ts.p.treeANode === -1 && !ts.p.scroll) {
        emptyRows(t,false, false);
        rcnt=1;
    } else { rcnt = rcnt > 1 ? rcnt :1; }
} else { return; }

and then extanded with the new creterias needed for Tree Grid.

2) If you call $.jgrid.randId() two times one after another

var id1 = $.jgrid.randId(), id2 = $.jgrid.randId();

you will receive very qrequently the same values in id1 and id2. The reason is that the timestamp (new Date().getTime()) will be not changed in so short time interval. So I suggest to change the lines 124-126 of grid.base.js to the following (not perfect but working sloution):

idCounter: 0, lastId:'', idPrefix: 'g',
randId : function() {
    var newId = String(new Date().getTime());
    if (newId === $.jgrid.lastId) {
        $.jgrid.idCounter++;
        newId += $.jgrid.idCounter; // make loger vesrion of id by appending the counter after the timestamp
    } else {
        $.jgrid.lastId = newId;     // we save in lastId only timestamp part of the id
        $.jgrid.idCounter = 0;      // reset counter to hold not too long ids
    }
    return $.jgrid.idPrefix+newId;
}, 

3) In the lines 360-364 and 422-426 contain the code:

if(isIE) {
    if(!cm.searchoptions.size) {
        cm.searchoptions.size = 10;
    }

all the lines should be removed. Probably you wanted to test for cm.searchoptions.multiple equal to true? At least the current code is wrong. It follow that the fearch dialog like

Image Enlarger

will be shown instead of

Image Enlarger

4) I suggest to remove lines 359 and 421 of grid.filter.js having

cm.searchoptions.id = $.jgrid.randId();

code because of two reason. A) I don't see that the lines really required for correct working of the grid.filter.js B) In case of the uasge dataUrl with multiple creteriums on one select field the current implementation can produce id duplicates. (see my answer to the question on the stackoverflow.com). The situation is not so easy. The problem is that you write id property every time in the searchoptions of the same column. It one use value property instead of dataUrl then all work OK. In case of dataUrl usage instead the complete event can be executed after the last creteriums (see the picture above) ovewrite the searchoptions.id. So for all dialog fields will be used the same last generated id.

After removing the line cm.searchoptions.id = $.jgrid.randId(); all work OK.

5) The line 185 of the file grid.filter.js (inside of the function createTableForGroup())

var table = $("<table class='group ui-widget ui-widget-content' style='border:0px none;'><tbody>");

generate non-closed <table> tag (the closed tag for the last element <tbody> will be added automatically by jQuery, but not for its parent <table>). So I suggest to replace the line to

var table = $("<table class='group ui-widget ui-widget-content' style='border:0px none;'><tbody></tbody></table>");

6) The line 277 of the file grid.common.js (inside of the function setAttributes()) should be replaced to

var exclude = ['dataInit','dataEvents', 'value','dataUrl', 'buildSelect', 'sopt', 'searchhidden', 'defaultValue', 'attr'];

because current implementation insert sopt and other attributes from the searchoptions as the attributes of <select> element.

7) The line 364 in the file grid.common.js (inside of the function createEl())

if(!msl) { return false; }

should be removed. The current implementation the attribute role="option" will be set till the selected option. The rest <option> elements don’t receive the attribute.

8.) The line 102 of the file grid.common.js contain .first() jQuery function which exist starting from jQuery 1.4. If you want continue support of jQuery 1.3.2 one should replace it with for example .filter(':first').

9) The line 87 of the grid.formedit.js (inside of searchGrid() function)

var fil = $("<span><div id='"+fid+"' class='searchFilter' style='overflow:auto'></div></span>").insertBefore("#gview_"+$t.p.id);

contains <span> element as the parent of <div> element which is not permitted. The most browsers will probebly not produce any error in the case. Nevertheless it would be better to remove the <span> element, because it is not really needed.

10) The line 62 of the grid.formedit.js (inside of searchGrid() function)

IDs = {themodal:'editmod'+fid,modalhead:'edithd'+fid,modalcontent:'editcnt'+fid, scrollelm : fid},

should be replaced to

IDs = {themodal:'searchmod'+fid,modalhead:'searchhd'+fid,modalcontent:'searchcnt'+fid, scrollelm : fid},

It is possible situations where both gialogs can coexist.

Best regards
Oleg

20/03/2011
12:22
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 fixes. I have fixed the most of them exept 4.

The reason that we need the uniquie id is that the datepicker and autocomplete widgets does not work if there are no uniquie id. I think that these are used more as of dataUrl. So for now it will stay so and later we will try to fix the problem.

Kind 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.

21/03/2011
01:18
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hallo Tony,

I though about not yet solved problems which we discussed here and it seems to me I found the solution.

First of all about the problem with the randId function. The current implementation of randId generate not always unique ids. You use the local counter which you append to the randId(). It solves the problem not really. If we use not-unique prefix not-real-unique-id appended with 1,2,3  in one function and the same not-real-unique-id also appended with the same 1,2,3  in anothe function one can easy receive id duplicates. It is only the question of good (quick) JavaScript engine (like in the last versions of Chrome) and the quick processor.

So I researched a little in the Internet and found out very close probeles where jQuery UI used in the datapicker the expression new Date().getTime() and faild to generate the unique id (see http://bugs.jqueryui.com/ticket/3235)
randId : function(prefix) {
    return (prefix? prefix: $.jgrid.idPrefix) +
           ($.jgrid.guid++);
}, 

It will solve the problem with the generation of uniques ids. From the code of grig.base.js and grid.filter.js you should remove the counters which you recently added in the code. If you don't remove the counter at the end of id, you can continue to receive conflicts (like "jqg1"+11 und "jqg11"+1).


Next problem. In the grid.filter.js you call $.jgrid.createEl with 6 paremeters, where the last parameter is true. The function createEl defined in the 263 of the grid.common.js has only 5 parameters. I suggest to extend the function with the new paremeter assignUniqueId:

createEl : function(eltype,options,vl,autowidth,ajaxso,assignUniqueId) {

The next change is to extend parameters of setAttributes function also with the new paremeter assignUniqueId:

function setAttributes(elm, atr, assignUniqueId) {
    // ... all current code
    if (assignUniqueId) {
        $(elm).attr('id',$.jgrid.randId());
    }

The lines 298, 324, 412, 425, 438 should all use the assignUniqueId:

setAttributes(elem, options, assignUniqueId);

And the last change in the grid.common.js: To solve problem with asynchrone code execution and possible parallel ajax calls to get  dataUrl I suggest to use additional context parameter of jQuery.ajax where all informatin needed inside of success event handler will be solved:

$.ajax($.extend({
    url: options.dataUrl,
    context: {elem:elem,options:options,vl:vl, assignUniqueId:assignUniqueId},
    type : "GET",
    dataType: "html",
    success: function(data,status){
        var a, ovm = [], elem = this.elem, vl = this.vl,
            options = $.extend({},this.options),
            msl = options.multiple===true
;
        if(typeof(options.buildSelect) != "undefined") {
            var b = options.buildSelect(data);
            a = $(b).html();
        } else {
            a = $(data).html();
        }
        if(a) {
            $(elem).append(a);
            setAttributes(elem, options, this.assignUniqueId);
            options = bindEv(elem,options);
    ... 

I marked all changed parts of the code bold.

I suppose that the changes will solve all the problems which I described before in the bug report.

Best regards
Oleg

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
45 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