我在我的编辑模式上的 kendodropdown 列表上有问题..它无法获取需要作为其在编辑模式上的参数的 id..
这是我的cshtml或视图:
<div class="infoHeader">
Worker Availability</div>
<div class="main">
<input type="hidden" id="availabilityId" name="workerId" value="@workerId" />
<input type="hidden" id="posSelect" name="posSelect" value="@posSelect" />
<input type="hidden" id="hiddenUser" name="hiddenUser" value="@userId" />
<div>
<table id="availabilityGrid">
<thead>
<tr>
<th style="width: 50px">
</th>
<th style='text-align: center;'>
Available Day
</th>
<th style='text-align: center;'>
Start Time
</th>
<th style='text-align: center;'>
End Time
</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">
</td>
</tr>
</tbody>
</table>
<div id="modalEditWindow">
@using (Html.BeginForm("hiremodal", "Client", FormMethod.Post, new { id = "workerindexForm" }))
{
<div class="main">
<input id="ddlWorker" name="ddlWorker" class:"validate[required] inputLong" style="width: 250px;" required value="@ddlWorker2" />
<input type="hidden" id="availabilityIds" name="availabilityIds" />
</div>
<input type="submit" id="btnSaveContact" class="styledButton" value="Save" />
<button id="btnConfirmEditNo" class="styledButton">
No</button>
}
</div>
</div>
<script id="availabilityTemplate" type="text/x-kendo-tmpl">
<tr class='k-alt'>
<td>
<a href="/Worker/ViewProfilePage" id="btnEdit${ID}" class="k-button" style="text-decoration: none;">Hire</a>
<input type="hidden" id="availabilityIds${ ID }" name="availabilityIds" value="${ ID }" />
<input type="hidden" id="positionSelected${ PositionSelected }" name="positionSelected " value="${ PositionSelected }" />
<input type="hidden" id="workerId${ Worker_ID }" name="workerId" value="${ Worker_ID }" />
<input type="hidden" id="posCode ${ posCode }" name="posCode" value="${ posCode }" />
<input type="hidden" id="des${ des }" name="des" value="${ des }" />
</td>
<td>
${AvailableDay}
<input type="hidden" id="dllEditAvailableDay${ ID }" name="dllEditAvailableDay" value="${ AvailableDay }" />
</td>
<td>
${StartTime}
<input type="hidden" id="editTpStartTime${ ID }" name="editTpStartTime" value="${ StartTime }" />
</td>
<td>
${EndTime}
<input type="hidden" id="editTpEndTime${ ID }" name="editTpEndTime" value="${ EndTime }" />
</td>
</tr>
</script>
这是我的jQuery:
});'
对于我的 jQuery 网格和编辑模式:
var availabilityId = $("#availabilityId").val()
$("#availabilityGrid").kendoGrid({
scrollable: false,
sortable: true,
pageable: true,
dataSource: {
transport: {
read: {
url: '/Worker/SortedWorkerAvail?availabilityId=' + availabilityId + '&positionSelected=' + positionSelected,
dataType: "json",
type: "POST"
}
},
change: function (e) {
$(window.location.hash).click();
},
pageSize: 10
},
rowTemplate: kendo.template($("#availabilityTemplate").html().replace('k-alt', '')),
altRowTemplate: kendo.template($("#availabilityTemplate").html())
});
var educationId = $("#educationId").val()
// create modal pop up for delete confirmation
editwnd = $("#modalEditWindow").kendoWindow({
title: "Hire Worker",
modal: true,
visible: false,
resizable: false,
width: 600
}).data("kendoWindow");
$("[id^='btnEdit']").live("click", function (e) {
// get the object in the scope
var obj = $(this);
var row = obj.closest("tr").find("input[name=availabilityIds]").val();
$('#availabilityIds').attr('value', row);
alert(row);
// prevent to continue to default action
e.preventDefault();
editwnd.center().open();
// dropdown
var userId = $("#hiddenUser").val();
var posSelect = $("#posSelect").val();
$("#ddlWorker").kendoDropDownList({
dataTextField: "Day_LookID",
dataValueField: "ID",
autoBind: false,
optionLabel: {
Day_LookID: "--- Please Select Position ---",
ID: ""
},
// define custom template
template:
'#if(data.Day_LookID) {#<p>${ data.Day_LookID }</p>#}#' +
'#if(data.StartTime && data.EndTime) {#<p>${ data.StartTime } - ${ data.EndTime }</p>#}#',
dataSource: {
transport: {
read: {
url: '/Worker/LoadShiftDropdownList?userId=' + userId + '&posSelect=' + posSelect + '&availabilityIds=' + availabilityIds,
dataType: "json",
type: "POST"
}
}
}
});
var dropdownlist = $("#ddlWorker").data("kendoDropDownList");
dropdownlist.list.width(250);
});
名为availabilityIds的编辑模式中的隐藏ID是我想为我的下拉列表创建参数的ID
抱歉上面的长代码粘贴..我不能继续这个错误感谢那些可以提供帮助的人。