Se si desidera definire tooltip su ogni intestazione columnn, è possibile definire kendoTooltip sulla griglia di elementi thead come questo:
grid.thead.kendoTooltip({
filter: "th",
content: function (e) {
var target = e.target;
return $(target).text();
}
});
Questo dimostra il testo hover quando si passa l'intestazione ovunque, non solo sul testo nell'intestazione. Il suggerimento è mostrato anche quando la colonna ha una larghezza minima e il testo dell'intestazione non viene presentato/mostrato nella sua intera lunghezza o non viene mostrato affatto. Vedi example.
Ecco il codice completo dell'esempio a jsbin.com, nel caso in cui esso deve essere riprodotto in futuro:
HTML: *
<!DOCTYPE html>
<html>
<head>
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.default.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<link href="http://cdn.kendostatic.com/2013.1.319/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.1.319/js/kendo.all.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="grid"></div>
</body>
</html>
JavaScript:
var grid = $("#grid").kendoGrid({
dataSource: {
type: "odata",
transport: {
read: "http://demos.kendoui.com/service/Northwind.svc/Orders"
},
schema: {
model: {
fields: {
OrderID: {
type: "number"
},
Freight: {
type: "number"
},
ShipName: {
type: "string"
},
OrderDate: {
type: "date"
},
ShipCity: {
type: "string"
}
}
}
},
pageSize: 20,
serverPaging: true
},
height: 430,
columns: [{
field: "OrderID",
width: 250
}, {
field: "ShipName",
title: "Ship Name",
width: 200
}
]
}).data("kendoGrid");
grid.thead.kendoTooltip({
filter: "th",
content: function (e) {
var target = e.target; // element for which the tooltip is shown
return $(target).text();
}
});
un piccolo miglioramento: filtro: ".k-header .k-link span" punta più precisamente alla cella dell'intestazione. Quello in risposta rende il popup del filtro non visibile a volte a causa del tooltip che si frappone. – yogi