我使用jqGrid,我想集成一個JQuery datePicker裏面。它運行良好,直到我添加showOn:'button'。那樣,編輯就不再起作用了。我真的希望僅在點擊按鈕時彈出選擇器,因爲日期是我行的第一個單元格,並且我使用內聯編輯,因此每行選擇都顯示datepicker :-(。如果我在jqGrid之外使用相同的datepicker選項,它將起作用。問題與jQueryGrid中的jQuery datepicker與showOn:'按鈕'
請幫
function loadGrid() {
var getUrl = 'Transactions.aspx/GridData/?fundID=' + $('#fundID').val();
var lastSel = "";
jQuery("#list").jqGrid({
url: getUrl,
editurl: 'Transactions.aspx/Edit/',
datatype: 'json',
mtype: 'GET',
colNames: ['Date', 'Invested', 'Nb Shares', 'Price'],
colModel: [
{ name: 'Date', index: 'Date', width: 120, align: 'left', editable: true,
editoptions: {
size: 10, maxlengh: 10,
dataInit: function(element) {
$(element).datepicker({ dateFormat: 'dd/mm/yy', constrainInput: false, showOn: 'button', buttonText: '...' });
}
}
},
{ name: 'Invested', index: 'Invested', width: 100, align: 'right', editable: true, edittype: 'text' },
{ name: 'NbShares', index: 'NbShares', width: 110, align: 'right', editable: true, edittype: 'text' },
{ name: 'UnitValue', index: 'UnitValue', width: 150, align: 'right', editable: true, edittype: 'text'}],
onSelectRow: function(id) {
if (id && id !== lastSel) {
jQuery('#list').restoreRow(lastSel);
jQuery('#list').editRow(id, true);
lastSel = id;
}
},
pager: jQuery('#navbar'),
viewrecords: true,
height: 'auto',
caption: 'Transactions detail'
}).navGrid('#navbar', { edit: false, add: true, del: true });
jQuery("input[type=text]").css("width", "2em");
jQuery("#navbar table").css("margin", "0");
}
太棒了 - 這篇文章幫我弄清楚瞭如何使用datepicker。謝謝! – Cody 2011-08-03 17:02:40