我正在使用jqGrid 4.5.2 &上午使用自定義格式化程序在jqGrid行中的單元格中建立一個下拉框基於其他(隱藏)單元格的值。jQuery jqGrid - 網格行內的選擇框
下拉框的選擇從查詢結果構建到SQL表。另外,我還在其上添加了一行作爲教學信息。下拉被內置如下:
function getMsgs() {
$.ajax({
type: "GET",
url: myUrl,
dataType: "xml",
success: function(data) {
var select = $("#msglist");
var selectline = $("<option value='0'>Select Message</option>");
select.prepend(selectline);
$(data).find("Row").each(function() {
var ctid = $(this).find("CannedTextID").text();
var dtext = $(this).find("DisplayText").text();
var option = $("<option>" + dtext + "</option>");
option.prop("value", ctid);
select.append(option);
});
// make the instructional message unselectable
$("#msglist option[value='0']").attr("disabled", "disabled");
}
});
msgSelect = $("#msglist").select();
}
結果放入表單頁面&的HTML如下:
<form class="Messages" action="">
<select id="msglist" class="choices" name="msglist">
<option value="0" disabled="disabled">Select Message</option>
<option value="7"> Message2</option>
<option value="8"> Message3</option>
<option value="9"> Message4</option>
<option value="10"> Message5</option>
<option value="11"> Message6</option>
<option value="12"> Message7</option>
<option value="13">Intermittent problems</option>
<option value="14">Local Network Connectivity issue</option>
<option value="15">Message15</option>
</select>
</form>
在函數結束時,我設置一個全局變量msgSelect = $("#msglist").select();
在格式化,在哪裏下拉應該是符合條件的,我回:
return msgSelect[0].outerHTML;
這會顯示jqGrid中的下拉框,但不是顯示第一行= Select Message
作爲初始下拉框,而是顯示Message2
。在jqGrid行中,Select Message
變灰&不能被選中,但下拉列表默認爲第二行。 select
與我在頁面上的其他位置放置的下拉框中的HTML完全相同(即Select Message
已禁用,且未在任一位置設置爲默認值)。
爲什麼jqGrid自定義格式化程序不同地顯示HTML,即使代碼完全相同?