网格是可编辑的,复选框检查正常。但是当提交网格时,它将保存到db中作为未选中状态(最后一行除外)。有什么想法吗?
这是我的网格html:
<div class="k-widget k-grid col-md-11" id="ParticipantList" data-role="grid" style="overflow: visible;">
参与者ID
IDT参与者姓名
亲自
0
0
0
同一页面上的另一个网格,都遇到了同样的问题:
<div class="k-widget k-grid col-md-11" id="FamilyMemberList" data-role="grid" style="overflow: visible;">
<table role="grid" tabindex="0" aria-activedescendant="FamilyMemberList_active_cell">
<colgroup>
<col style="width:30%">
<col style="width:30%">
<col style="width:15%"><
col style="width:15%">
<col></colgroup>
<thead class="k-grid-header"><tr>
<th class="k-header" data-field="ParticipantID" data-title="Participant ID" scope="col" style="display:none" data-role="sortable"><a class="k-link" tabindex="-1">Participant ID</a>
</th><th class="k-header" data-field="ParticipantName" data-title="Name of person Invited" scope="col" data-role="sortable">
<a class="k-link" tabindex="-1">Name of person Invited</a></th>
<th class="k-header" data-field="Relationship" data-title="Relationship" scope="col" data-role="sortable" id="FamilyMemberList_active_cell"><a class="k-link" tabindex="-1">Relationship</a></th>
<th class="k-header" data-field="HasAttended" data-title="Attended" scope="col" data-role="sortable">
<a class="k-link" tabindex="-1">Attended</a></th>
<th class="k-header" data-field="IsInPerson" data-title="In Person" scope="col" data-role="sortable">
<a class="k-link" tabindex="-1">In Person</a></th>
<th class="k-header" scope="col"><span class="k-link"> </span></th></tr></thead>
<tbody>
<tr data-uid="b09ff8d6-04ab-4ff6-8db2-71cc10887fd4" role="row">
<td style="display:none" role="gridcell">0<input type="hidden" name="FamilyMemberList[0].ParticipantID" value="0"></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[0].ParticipantName" class="participantName0" value=""></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[0].Relationship" class="relationShip0" value=""></td>
<td role="gridcell"><input type="checkbox" class="HasAttendedChkBx"><input type="hidden" name="FamilyMemberList[0].HasAttended"></td>
<td role="gridcell"><input type="checkbox" class="InPersonChkBx"><input type="hidden" name="FamilyMemberList[0].IsInPerson"></td>
<td role="gridcell"><a class="k-button k-button-icontext k-grid-deletethisrow" href="#"><span class="glyphicon glyphicon-trash"></span></a></td>
</tr>
<tr class="k-alt" data-uid="6689f6db-9bda-41c0-9932-655522267838" role="row"><td style="display:none" role="gridcell">0<input type="hidden" name="FamilyMemberList[1].ParticipantID" value="0"></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[1].ParticipantName" class="participantName1" value=""></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[1].Relationship" class="relationShip1" value=""></td>
<td role="gridcell"><input type="checkbox" class="HasAttendedChkBx"><input type="hidden" name="FamilyMemberList[1].HasAttended"></td>
<td role="gridcell"><input type="checkbox" class="InPersonChkBx"><input type="hidden" name="FamilyMemberList[1].IsInPerson"></td>
<td role="gridcell"><a class="k-button k-button-icontext k-grid-deletethisrow" href="#"><span class="glyphicon glyphicon-trash"></span></a></td></tr>
<tr data-uid="f7610caf-3cc5-4592-8f13-b3a0a933179f" role="row" class="">
<td style="display:none" role="gridcell" class="" data-role="editable">0<input type="hidden" name="FamilyMemberList[2].ParticipantID" value="0"></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[2].ParticipantName" class="participantName2" value=""></td>
<td role="gridcell"><span> </span><input type="hidden" name="FamilyMemberList[2].Relationship" class="relationShip2" value=""></td>
<td role="gridcell"><input type="checkbox" class="HasAttendedChkBx"><input type="hidden" name="FamilyMemberList[2].HasAttended"></td>
<td role="gridcell"><input type="checkbox" class="InPersonChkBx"><input type="hidden" name="FamilyMemberList[2].IsInPerson"></td>
<td role="gridcell"><a class="k-button k-button-icontext k-grid-deletethisrow" href="#"><span class="glyphicon glyphicon-trash"></span></a></td></tr></tbody>
</table>
jquery的:
$('#FamilyMemberList').on('click', '.HasAttendedChkBx', function () {
var hasAttendedHiddenInput = $(this).siblings("input[type='hidden']");
if ($(this).is(":checked")) {
hasAttendedHiddenInput.val("true");
console.log('FamilyMemberList - hasAttended' + hasAttendedHiddenInput.val());
} else {
hasAttendedHiddenInput.val("");
console.log('FamilyMemberList - hasAttended' + hasAttendedHiddenInput.val());
}
});
$('#CareConferenceParticipantList').on('click', '.IsInPersonChkBx', function (e) {
var isInPersonHiddenInput = $(this).siblings("input[type='hidden']");
if ($(this).is(":checked")) {
isInPersonHiddenInput.val("true");
console.log('FamilyMemberList - inPerson' + isInPersonHiddenInput.val());
} else {
isInPersonHiddenInput.val("");
console.log('FamilyMemberList - inPerson' + isInPersonHiddenInput.val());
}
});
任何帮助都会非常感激,谢谢