Hello Tonny,
because jqGrid is the main and most important control in my last project I decide to spend more time in the analyze of JSLint suggestions to jqGrid code.
Now I place without any comments different suggestions unsorted. Important real bug fixes are mixed below with less important performance improvements and style changes. I bag pardon of all who read my bad English below.
But, before all, one general remark: JSLint suggest to use ‘!==’ instead of ‘!=’ and ‘===’ instead of ‘!=’ to suppress possible type conversion during compare values and to have strange effects with undefined variables. Another general suggestion is the usage of {…} block in all ‘if’ statements. It seems to me, that you hold the role currently, but in some most old places there is no {…} block. What do you think about inserting {…} block everywhere in the code.
The line 267 of grid.celledit.js:
window.setTimeout(function() { info_dialog($.jgrid.errors.errcap, v + ” “ + cv[1], $.jgrid.edit.bClose) }, 100);
hat missing semicolon and should be replaced to
window.setTimeout(function() { info_dialog($.jgrid.errors.errcap, v + ” “ + cv[1], $.jgrid.edit.bClose); }, 100);
The line 290
if ($.isFunction($.fn['datepicker'])) {
Should be better rewritten as
if ($.isFunction($.fn.datepicker)) {
Line 420 and 442 has unnecessary semicolon at the end of line.
Line 474
res[“id”] = this.id;
can be better rewritten as
res.id = this.id;
File grid.common.js
Function DaysArray define in the line 591 and used in the line 557 should be better renamed to daysArray to hold the name conversion.
Line 602
if (val.match(/^s+$/) || val === “”) {
of the function isEmpty should better fixed to
if (val !== null || val.match(/^s+$/) || val === “”) {
Function isArray from the lines 244-250 are used only in the line 1308 of grid.formedit.js. In grid.formedit.js isArray should be replaced to jQuery.isArray like in all other places of jqGrid and the function isArray removed from the lines 244-250 of grid.common.js. If you decide to hold isArray in grid.common.js, it should be better fixed in the line 245 from
if (obj.constructor.toString().indexOf(“Array”) == -1) {
To
if (obj && obj.constructor.toString().indexOf(“Array”) == -1) {
The lines 79-80 of the file grid.custom.js
$(newtable).attr({id:defgrid['id']});
newtable.className = defgrid['cl'];
could be rewritten to
$(newtable).attr({id:defgrid.id});
newtable.className = defgrid.cl;
In the line 95
$t = this;
Would be better to insert “var”:
var $t = this;
In the line 106
if($t.p.footerrow) {$(“.ui-jqgrid-sdiv”,“#gbox_”+$s.p.id).slideUp(“fast”);}
there is a bug with using undefined variable $s. It should be fixed to $t.
The line 112
if(ts.p.toppager) {$(ts.p.toppager).slideDown(“fast”);}
Should be changed to
if($t.p.toppager) {$($t.p.toppager).slideDown(“fast”);}
switch from the line 263
switch (this.stype) {
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top