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_TopicIcon
Checkbox click event in edit form
21/11/2013
10:53
Avatar
dikrid
Member
Members
Forum Posts: 12
Member Since:
26/07/2013
sp_UserOfflineSmall Offline

Hi,

I have a column with a checkbox and want to react on a click inside the edit form (where the checkbox is visible and clickable). The reason is, that I want to set some textboxes inside the edit form depending on the checkbox's value (0:1). I found Oleg's code:

    var iCol = getColumnIndexByName ($(this), 'ebl'), rows = this.rows, i,
              c = rows.length;
          
              for (i = 1; i < c; i += 1) {
                  $(('input[type="checkbox"]'),rows[i].cells[iCol]).click(function (e) {
                      var id = $(e.target).closest('tr')[0].id,
                          isChecked = $(e.target).is(':checked');
                      alert('clicked on the checkbox in the row with id=' + id +
                            '\nNow the checkbox is ' +
                            (isChecked? 'checked': 'not checked'));
                  });
              }

That does work inside the grid, but not in the edit form. How would  I need to change the function? And would it have to be called in beforeShowForm of the edit form?

Thanks,

dikrid

21/11/2013
13:04
Avatar
dikrid
Member
Members
Forum Posts: 12
Member Since:
26/07/2013
sp_UserOfflineSmall Offline

I solved it this way (after analysing the html code):

var tabform = document.getElementById('TblGrid_grid');

                var iCol = 1, rows = tabform.rows, i,
                    c = rows.length;

                for (i = 1; i < c; i += 1) {
                  $(('input[type="checkbox"]'),rows[i].cells[iCol]).click(function (e) {
                      var id = $(e.target).closest('tr')[0].id,
                          isChecked = $(e.target).is(':checked');
                 
                      alert('clicked on the checkbox in the row with id=' + id +
                            '\nNow the checkbox is ' +
                            (isChecked? 'checked': 'not checked'));
                  });
              }

It can surely be optimized by finding iCol, et cetera, but I can work with this.

Thanks anyway,

dikrid

25/11/2013
18:26
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thank you for sharing your solution. Every solution is ok if it do the job.

Regards

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.

27/11/2013
13:00
Avatar
dikrid
Member
Members
Forum Posts: 12
Member Since:
26/07/2013
sp_UserOfflineSmall Offline

Hi tony,

you're welcome. Thanks for your answer, I'm glad I could help a bit too 🙂

bye,

dikrid

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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