我想在特定列上設置圖像,但是當我使用formatter
設置時,我沒有得到預期的結果。圖像是壓倒一切的數據。在.jqGrid中的過濾條旁邊設置圖像
$(function() {
"use strict";
$("#myDialogBox").dialog({
autoOpen: false
});
$("#grid").jqGrid({
colModel: [
{ name: "BatchID", label: "Batch ID", align: "center"},
{ name: "Status", label: "Status", align: "center", formatter: "select",
formatoptions: { value: "CAN:Canceled; COM:Completed; PEN:Pending", defaultValue: "PEN" },
stype: "select", searchoptions: { value: ":Pending;CAN:Canceled; COM:Completed"} },
{ name: "StartRunDate", label: "Start Run Date", align: "center", sorttype:"date",
formatter: function() { return "<img src='http://jqueryui.com/resources/demos/datepicker/images/calendar.gif' alt='calendar' />"; },
formatoptions: { newformat: "d-M-Y" } },
{ name: "StartRunTime", label: "Start Run Time", align: "center", sorttype:"time", formatter: "time" },
{ name: "EndRunDate", label: "End Run Date", align: "center", editable:true, sorttype:"date" },
{ name: "EndRunTime", label: "End RunTime", align: "center", editable:true, sorttype:"time" },
{ name: "Action", label: "Action", align: "center", formatter: "showlink"},
{ name: "JobID", label: "Job ID", align: "center" },
{ name: "JobName", label: "Job Name", align: "center"},
{ name: "ConceptName", label: "Concept Name", align: "center" },
{ name: "StartDate", label: "Start Date", align: "center" },
{ name: "EndDate", label: "End Date", align: "center" },
{ name: "Frequency", label: "Frequency", align: "center",
\t formatter: "select",
formatoptions: { value: "ALL:All; DAI:Daily; WEK:Weekly", defaultValue: "ALL" },
stype: "select",
searchoptions: { value: ":All; DAI:Daily; WEK:Weekly" } },
{ name: "QueryLink", label: "Query Link", align: "center",
formatter: function() { return '<button class="popup-trigger">Pop Up</button>' } },
{ name: "Submitter", label: "Submitter", align: "center"}
],
data: [
{ BatchID: "1", Status: "Pending", StartRunDate: "7/12/2017", StartRunTime:"12:00", EndRunDate: "7/12/2017",
EndRunTime:"1:00", Action: "Cancel Delivery", JobID: "123", JobName: "Test", ConceptName: "CPK", StartDate: "7/12/2017", EndDate: "7/12/2017", Frequency: "All", QueryLink: "Link", Submitter: "John Doe"
}],
iconSet: "fontAwesome",
rownumbers: true,
sortname: "invdate",
sortorder: "desc",
caption: ".jqGrid Test"
}).jqGrid('filterToolbar', {autoSearch: true}).on('click', '.popup-trigger', function() {
$("#myDialogBox").dialog("open");
});
});
<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.13.6/js/jquery.jqgrid.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/free-jqgrid/4.14.0/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"/>
<table id="grid"></table>
<div id="myDialogBox" title="Basic dialog"></div>
預期的結果:想要日曆旁邊x
圖標。
缺少什麼我在這裏?這裏有什麼.jqGrid
限制?
我不知道,我明白你的問題。當前代碼格式化輸入數據'「7/12/2017」'作爲圖標。如果您在「StartRunDate」列的過濾器工具欄中輸入字符串「7/12/2017」,則會獲得按值過濾的數據:一行。如果您在過濾器工具欄中輸入任何其他值爲'7/12/2017'(例如'8/12/2017'),然後按Enter鍵,則不會顯示任何行。 – Oleg
@ Oleg抱歉的混淆。我希望圖標所在的'x'和'7/12/2017'旁邊有'日曆'圖標。搜索很好。我在設置濾鏡欄旁邊的圖標時遇到問題。我現在正在做的是用我不想要的圖像取代「2017年7月12日」。 – CSharper