Forum



19:27

16/08/2010

Hello I want to get the id (or something) of current clicked column, because i have a multiselect grid and when user click over checkbox I don't want to edit this row
my code is:
viewrecords: true,
multiboxonly: false,
multiselect: true,
onSelectRow: function(id){
….
}
but in this code I only have the id of row no the id of column
is it possible???
Thanks!
23:19

10/08/2009

Hello tunyafix,
jqGrid don't support in the onSelectRow any information about the column where the user clicked it. It seems to me you can receive the same information manually using jQuery. The code can look about following
var el = e.target; // DOM of the HTML element which was clicked
if (el.nodeName !== "TD") {
// in case of the usage of the custom formatter we should go to the next
// parent TD element
el = $(el,this.rows).closest("td");
var iCol = $(el).index();
var row = $(el,this.rows).closest("tr.jqgrow");
var rowId = row[0].id;
// now you can do what you need. You have iCol additionally to rowId
}
}
I created a small demo for you.
Be careful with the column numeration. There are additional column if you use the rownumbers: true and of cause one more column with the checkboxes.
Best regards
Oleg
09:56

16/08/2010

Hello Oleg, thank you very much!!!
I have to adjust my script because onSelectRow is launched before click and then I change to:
jQuery("#grid").jqGrid({
...
onSelectRow: function(id){
if(id>0){
jQuery('#grid').jqGrid('restoreRow',lastsel3);
jQuery('#grid').jqGrid('editRow',id,true);
lastsel3=id;
}
}
});
jQuery("#grid").click(function(e) {
var el = e.target;
if (el.nodeName !== "TD") {
el = $(el,this.rows).closest("td");
}
var iCol = $(el).index();
var nCol = $(el).siblings().length;
var row = $(el,this.rows).closest("tr.jqgrow");
var rowId = row[0].id;
if (iCol==0) {//When checkbox is clicked then restore row
jQuery('#grid').jqGrid('restoreRow',rowId);
}
});
Greetings!
Antoni
Most Users Ever Online: 715
Currently Online:
56 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