Forum
03:56
11/04/2011
The stated goal of Tony and the team is to maintain backward compatibility when adding features. This is normal and good practice.
In version 3.8, a "feature" was added to allow clicking on a selected row in NON-multiselect mode which would deselect that row. This is directly contrary to the prior feature that clicking on a selected row keeps it selected. The prior behavior is NOT a bug.
By changing this behavior you break backward compatibility. This new mode should require a flag to enable it.
Example- deselectWhenReselect: true;
The new feature is the one that should require the flag, since the old behavior did not require one and requiring a flag for the old behavior, also breaks backward compatibility.
I was using the prior behavior. When the user clicks a row, A) it highlights so the user has a visual indicator of which row they selected. Then, using OnSelectedRow, I open an overlay with information, much like a lightbox. When the user is done, they close the overlay, revealing the grid, once again, with the row they selected still highlighted, as a visual reference. All this happens automatically. However, information changes and the user may wish to select the same row again to open the overlay once more.
Before, in version 3.7, this worked. Now, the row deselects and the user gets nothing. They have to click a second time to get their overlay. For my project, this is bad human interface design, and frankly, annoying to the user. There is no way for me to override this behavior without actually changing the source code.
I can go back to version 3.7, but I upgraded to 3.8 because I wanted to start using the grouping function. So, now, I am faced with one of two options.
1) I can go back to version 3.7 and try to get by without any of the new features.
2) I can upgrade, but make custom changes to the code to get back the functionality I need. I have to remember and make these custom change from now on, everytime I upgrade, which, is definitely not good practice for code maintenance.
It is important to keep existing features in place and not disable them when adding new features.
The 3.7.2 code: from grid.base.js Lines 2347-2349
$t.p.selrow = pt.id;
$(pt).addClass("ui-state-highlight").attr("aria-selected","true");
if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow.call($t,$t.p.selrow, true); }
New faulty 3.8.2 code from grid.base.js Lines 2419-2423
if( $t.p.selrow != pt.id) {
$t.p.selrow = pt.id;
$(pt).addClass("ui-state-highlight").attr("aria-selected","true");
if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow.call($t,$t.p.selrow, true); }
} else {$t.p.selrow = null;}
The corrected code follows (this is untested):
if( $t.p.selrow != pt.id || !$t.p.deselectWhenReselect) {
$t.p.selrow = pt.id;
$(pt).addClass("ui-state-highlight").attr("aria-selected","true");
if( $t.p.onSelectRow && onsr) { $t.p.onSelectRow.call($t,$t.p.selrow, true); }
} else {$t.p.selrow = null;}
Add the following after line 633 (the line with multiselect: false,)
deselectWhenReselect: false,
09:44
Moderators
30/10/2007
Hello,
Thank you for the recommendation.
Actually from this point our goal is not to add additional options into the grid.
The reason is simple. The grid has a thausand of options and sometime I can not remmember all.
You understand what I mean.
For this purpose to have deleseleced row (When this was introduced a lot of people say why you have a row deselection? This brake my applicatrion! and etc)
I have introduced a id parameter in resetSelection method.
The appropriate code is
onSlectRow : function( id, selected)
{
if(selected === false) { $("#grid").resetSelection( id); }
}
This way everybody is happy
1. jqGrid team – there are no more additional options
2. You – you have a single line of code for deselection
3. All other that do not like the deselection.
Kind 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.
Most Users Ever Online: 715
Currently Online:
55 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66