我想將自定義按鈕添加到Kendo Grid的每一行,但我沒有獲得所需的輸出。所以我的要求是將動態按鈕添加到每一行,點擊這些按鈕我需要處理的東西,我需要很少的列值傳遞到該按鈕點擊。如何在Kendo Grid的每一行中添加自定義按鈕
我已經試過類似
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.Id);
columns.Bound(o => o.TBRId).Width(100).Title(UI_Resources.ListLabel_TBRId);
columns.Bound(o => o.THUQuantity).Width(50).Title(UI_Resources.ListLabel_THUQuantity).HtmlAttributes(new { style = "text-align:right" });
columns.Bound(o => o.Id).ClientTemplate("<input width='50px' type='button' value= " + UI_Resources.Button_Details + " onclick='onDetailUnitClick(#= Id #);' class='btn btnTable' />").Width(50).Title("");
columns.Bound(o => o.IsPOD).ClientTemplate("#= AppendZeroPODButton(Id,IsPOD) #").Width(60).Title("");
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetUnitsForShipment", "POD",new { shipmentId = @Model, Mode = "POD" }))
)
)
/*JavaScript */
function onDetailUnitClick(Id) {
var podDateTime = $("#enteredPODDateTime").val();
var stopId = $("#hiddenStopId").val();
var mode = '';
if (typeof $("#hiddenMode").val() != 'undefined')
mode = $("#hiddenMode").val();
window.location.href = "/POD/Details/" + Id + "?stopId=" + stopId + "&date=" + podDateTime + "&mode=" + mode;
};
function AppendZeroPODButton(Id, isPOD) {
if (isPOD == true) {
return "<input width='100px' type='button' value= 'Zero POD' onclick='onPODUnitClick(" + Id + ",1);' class='btn btnTable btn-success' disabled />";
}
else {
return "<input width='100px' type='button' value= 'Zero POD' onclick='onPODUnitClick(" + Id + ",1);' class='btn btnTable btn-danger' />";
}}
能否請你建議我什麼我做錯了!它正在爲Telerek MVC電網工作。
感謝 約根德拉·辛格