Forum


19:24

21/12/2009

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
10:55

Moderators
30/10/2007

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.
18:21

21/12/2009

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(
"/>");
18:30

Moderators
30/10/2007

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.
12:05

21/12/2009

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
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66