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
Get clicked column id
Tags: column
24/11/2010
19:27
Avatar
tunyafix
Member
Members
Forum Posts: 7
Member Since:
16/08/2010
sp_UserOfflineSmall Offline

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!

24/11/2010
23:19
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

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

$("#list").click(function(e) {
    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 


25/11/2010
09:56
Avatar
tunyafix
Member
Members
Forum Posts: 7
Member Since:
16/08/2010
sp_UserOfflineSmall Offline

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

Forum Timezone: Europe/Sofia

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

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

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information