1
我在.jqGrid
中使用.timepicker
與filterToolbar
。我想添加一個圖像旁邊的過濾器欄,用戶應該看到他們點擊圖像時的時間。無法在日期選擇器中添加圖像
如果我只是使用$(element).timepicker();
然後我看到我點擊過濾器欄的時間,但當我跟着時,timepicker
根本不工作。
$(element).timepicker({
showOn: "button",
buttonImage: "https://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
});
相同的選項與datepicker
一起使用。我在這裏錯過了什麼?這是由於jquery.timepicker.js
版本?
工作演示
$(function() {
"use strict";
$("#grid").jqGrid({
colModel: [{
name: "StartRunTime",
label: "Start Run Time",
align: "center",
sorttype: "time",
formatter: "time",
searchoptions: {
dataInit: function(element) {
$(element).timepicker();
}
}
}],
data: [{
StartRunTime: "12:00"
}],
caption: ".jqGrid Test"
}).jqGrid('filterToolbar', {
autoSearch: true
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/jquery.jqgrid.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.9/jquery.timepicker.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/css/ui.jqgrid.min.css" rel="stylesheet" />
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.9/jquery.timepicker.css">
<table id="grid"></table>
不工作演示
$(function() {
"use strict";
$("#grid").jqGrid({
colModel: [{
name: "StartRunTime",
label: "Start Run Time",
align: "center",
sorttype: "time",
formatter: "time",
searchoptions: {
dataInit: function(element) {
$(element).timepicker({
\t \t showOn: "button",
\t \t buttonImage: "https://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
\t buttonImageOnly: true,
});
}
}
}],
data: [{
StartRunTime: "12:00"
}],
caption: ".jqGrid Test"
}).jqGrid('filterToolbar', {
autoSearch: true
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/jquery.jqgrid.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.9/jquery.timepicker.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.1/css/ui.jqgrid.min.css" rel="stylesheet" />
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/redmond/jquery-ui.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-timepicker/1.8.9/jquery.timepicker.css">
<table id="grid"></table>
這是有道理的,但它增加了一個形象,如果所有列我添加任何。這裏是鏈接,[jsfiddle](https://jsfiddle.net/gunjan_prmr/kkxa62wb/)。從給定的例子,我怎麼才能將它添加到'StartRunTime'列? – CSharper
調用'.parent()。after()'更新了答案。 – ewwink
這個工程。謝謝。 – CSharper