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
how to assoicate parent checkox to subgrid checkbox
21/12/2009
19:24
Avatar
yenkumar
Member
Members
Forum Posts: 4
Member Since:
21/12/2009
sp_UserOfflineSmall Offline

Hi,

 I am new to jqgrid. I have some issues regarding the checkboxes in jqgrid.

I created a checkbox in parent grid and also in subgrid.

How do i associate both the grids. i.e. when i check the parent checkbox i need the child element also to be checked and vice versa.  I am using json datatype.

Looking for help ASAP.

regards,

Nagendra Kumar Yenugula

22/12/2009
10:55
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

How do you create the checkbox? - manually using the formatter or you just set multiselect to true?

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.

30/12/2009
18:21
Avatar
yenkumar
Member
Members
Forum Posts: 4
Member Since:
21/12/2009
sp_UserOfflineSmall Offline

tony said:

Hello,

How do you create the checkbox? – manually using the formatter or you just set multiselect to true?

Regards

Tony


Hi Tony,

I created the checkbox using java. Below is the code.

No, i didn't use formatter or multiselect. Please let me know if there is better approach to what i am using.

checkbox.append(



"<input type=\\"checkbox\\" ").append("id=\\"purchaseOrder[").append(index).append("]_[").append(count).append("]\\"").append(" "

);

checkbox.append(

"name=\\"selectedOrderValues\\"").append(" ").append("value=\\"").append(element.getPurchaseOrder()).append("\\"").append(" "

);

checkbox.append(

"onclick=\\"javascript:clickParentEvent('").append(index).append("','").append(itemElementSize).append("')").append("\\""

);

checkbox.append(

"/>");



03/01/2010
18:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

If you know the id's of both grids you can attach a onclick event to every check box and perform the needed actions

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.

13/01/2010
12:05
Avatar
yenkumar
Member
Members
Forum Posts: 4
Member Since:
21/12/2009
sp_UserOfflineSmall Offline

tony said:

Hello,

If you know the id's of both grids you can attach a onclick event to every check box and perform the needed actions

Regards

Tony


Hi Tony,

   This is the way i have resolved the issues.....

   Parent ID : chkPO_<PONumber> as per the application.

   Child ID : chkPOItems_<PONumber>

    <!--   Use JQuery wildcard selector to find all checkboxes which start with poItemId -->
    function togglePOItemsCheckbox(parent) {
    var poItemId = 'chkPOItems_' + parent.id.substr(parent.id.indexOf('_') + 1) + '_';
    $('[id^=' + poItemId + ']input:checkbox').attr('checked', parent.checked);
    }

    function togglePOCheckbox(child) {
    var po = child.id.substring(child.id.indexOf('_') + 1, child.id.lastIndexOf('_'));

    // Check if any of the child checkboxes are checked
    var isChecked = $('[id^=chkPOItems_' + po + ']input:checkbox').is(":checked");

    $('[id^=' + 'chkPO_' + po + ']input:checkbox').attr('checked', isChecked);
    }

and in the subgrid add these lines.

                        gridComplete: function () {
                            // subgrid id contains the po number, remove 'jsonmap_' and '_t' form the id to get po number
                            var po = this.id.substring(this.id.indexOf('_') + 1, this.id.lastIndexOf('_'));                   
                            // Determine if parent check box is checked
                            var isParentChecked = $('[id=' + 'chkPO_' + po + ']input:checkbox').attr('checked');
                            // Set checkboxes in the subgrid
                            $('[id^=' + 'chkPOItems_' + po + '_' + ']input:checkbox').attr('checked', isParentChecked);
                        }

Regards,

Nagendra Kumar Yenugula

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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