0
我似乎無法得到選擇kendo UI網格(網絡)方法來選擇一行(或任何事情)。我在另一篇文章中讀到了將div ID包含在選擇器中,但這也沒有幫助。爲簡單起見,我試圖做到這一點在telerick的例子在這裏:http://dojo.telerik.com/oNeR選擇方法不選擇Kendo UI Grid行
我會想到的是,第一行會自動選擇加入:
var gridRow = $("#rowSelection").data("kendoGrid");
gridRow.select("tr:eq(0)");
完整的例子:
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/grid/selection">
<style>html { font-size: 12px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link href="http://cdn.kendostatic.com/2014.2.903/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.903/styles/kendo.default.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.903/styles/kendo.dataviz.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.903/styles/kendo.dataviz.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.2.903/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.903/js/angular.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.903/js/kendo.all.min.js"></script>
</head>
<body>
<script src="../content/shared/js/orders.js"></script>
<div id="example">
<div class="demo-section k-header">
<h4>Grid with multiple row selection enabled</h4>
<div id="rowSelection"></div>
</div>
<div class="demo-section k-header">
<h4>Grid with multiple cell selection enabled</h4>
<div id="cellSelection"></div>
</div>
<script>
$(document).ready(function() {
$("#rowSelection").kendoGrid({
dataSource: {
data: orders,
pageSize: 6
},
selectable: "single",
pageable: {
buttonCount: 5
},
scrollable: false,
navigatable: true,
columns: [
{
field: "ShipCountry",
title: "Ship Country",
width: 300
},
{
field: "Freight",
width: 300
},
{
field: "OrderDate",
title: "Order Date",
format: "{0:dd/MM/yyyy}"
}
]
});
$("#cellSelection").kendoGrid({
dataSource: {
data: orders,
pageSize: 6
},
selectable: "multiple cell",
pageable: {
buttonCount: 5
},
scrollable: false,
navigatable: true,
columns: [
{
field: "ShipCountry",
title: "Ship Country",
width: 300
},
{
field: "Freight",
width: 300
},
{
field: "OrderDate",
title: "Order Date",
format: "{0:dd/MM/yyyy}"
}
]
});
});
var gridRow = $("#rowSelection").data("kendoGrid");
gridRow.select("tr:eq(0)");
</script>
</div>
</body>
</html>
閱讀有關數據綁定我認爲作品。但是,事實並非如此。它引發TypeError:'undefined'在執行select方法時不是一個對象(評估'o.options')。也不能在Kendo dojo測試應用程序中使用。 – user1489995 2014-09-08 12:44:50
@ user1489995我已經在http://dojo.telerik.com/EKOm上修復了您的Dojo - 您需要稍微不同地聲明您的數據源。你能否在你的問題中包含orders.js(不必使用真實數據)。它是一個對象數組嗎? – pwdst 2014-09-08 21:52:13