已编辑 JS:
$.extend($.jgrid.defaults,
{
mtype: "POST",
viewRecords: true,
rowNum: 10,
sortable: false,
shrinkToFit: true,
rowList: [10,20,50],
xmlReader: {
root: "tasks",
row: "task",
repeatitems: false
}
});
<script>
var subjects = <?php echo $Subject ?>;
var users = <?php echo $trimmed ?>;
var lastsel3;
$(document).ready(function () {
$grid = $("#assign"),
initDateEdit = function (elem) {
setTimeout(function() {
$(elem).datepicker({
dateFormat: 'yy-mm-dd',
showButtonPanel: true
});
}, 100);
},
initDateSearch = function (elem) {
setTimeout(function() {
$(elem).datepicker({
dateFormat: 'yy-mm-dd',
showButtonPanel: true
});
}, 100);
};
$grid.jqGrid({
url: 'assignedTasks.php',
colNames: ["track","Assigned To","JobID","Subject","Notes","Details","Due Date","Submit Date", "AssignUser"],
colModel: [
{
name: "track",
index:"TrackID",
key: true,
align: "center",
xmlmap:"TrackID",
hidden: true
},
{
name:"User",
index:"UserID",
align: "center",
editable: true,
xmlmap:"UserID",
edittype: 'select',
editoptions: {value: users},
editrules: {required: true},
sortable: false
},
{
name: "JobID",
index:"TaskID",
xmlmap:"TaskID",
editable: true,
align:"center",
editrules: {required: true},
sortable: false,
},
{
name: "Subject",
index:"TaskSubject",
align: "center",
xmlmap:"TaskSubject",
editable: true,
edittype: 'select',
editoptions: {value: subjects},
editrules: {required: true},
sortable: false
},
{
name:"Notes",
index:"Notes",
align: "center",
height: 20,
xmlmap:"Notes",
editable: true,
edittype: 'textarea',
sortable: false
},
{
name:"Details",
index:"Details",
align: "center",
xmlmap: "Details",
editable: false,
sortable: false
},
{
name:"DueDate",
index:"DueDate",
align: "center",
editable: true,
xmlmap:"DueDate",
editrules:{required: true},
editoptions: {dataInit: initDateEdit},
formatter: 'date',
formatoptions: {newformat: 'd-M-Y'},
datefmt: 'd-M-Y',
sortable: false
},
{
name:"Submitted",
index:"Submitted",
align: "center",
xmlmap: "Submitted",
editable: false,
sortable: false
},
{
name:"AssignUser",
index:"AssignUser",
align: "center",
xmlmap: "AssignUser",
hidden:true,
editable: false
}
],
loadComplete : function()
{
var rows = $grid.jqGrid('getDataIDs');
alert(rows);
for (ID in rows)
{
var data = $grid.getCell(ID,'Details');
alert(data);
}
},
gridview: true,
ondblClickRow: function(track){
if(track && track!==lastsel3)
{
$('#assign').jqGrid('restoreRow',lastsel3);
$('#assign').jqGrid('viewGridRow',track);
lastsel3=track;
}
else
{
$("#assign").jqGrid('viewGridRow',track);
}
},
editurl: 'addTasks.php',
pager: $('#assignNav'),
caption: "Assign Tasks"
}).navGrid('#assignNav',{edit:true,add:true,del:true},{},{},{},{multipleSearch: false, multipleGroup: false});
$(window).bind('resize', function() {
$("#assign").setGridWidth($(window).width()-"185");
$("#assign").setGridHeight($(window).height()-"310");
}).trigger('resize');
});
setInterval(
function(){
$('#assign').setGridParam({datatype: 'xml'}).trigger('reloadGrid',[{current:true}]);
},60000);
</script>
我正在使用此事件来获取单元格内的值。当我运行代码时,警报会为前几个单元格返回“false”,即使它们已分配值,然后返回所有相应值的正确值。我该如何解决? 我尝试了gridComplete事件,结果是一样的。
XML:
<?xml version="1.0" encoding="UTF-8" ?>
<tasks>
<task>
<TaskID>job0001</TaskID>
<UserID>admin</UserID>
<AssignID></AssignID>
<AssignDate></AssignDate>
<DueDate></DueDate>
<AssignUser>1</AssignUser>
<TaskSubject></TaskSubject>
<Notes>Urgent!</Notes>
<TrackID>1</TrackID>
<Details>Not Started</Details>
<Submitted></Submitted>
<folderLink></folderLink>
</task>
<task>
<TaskID>job00004</TaskID>
<UserID>admin</UserID>
<AssignID></AssignID>
<AssignDate>2012-02-07</AssignDate>
<DueDate>2012-02-16</DueDate>
<AssignUser>1</AssignUser>
<TaskSubject></TaskSubject>
<Notes>ajsbaljb</Notes>
<TrackID>7</TrackID>
<Details>Not Started</Details>
<Submitted></Submitted>
<folderLink></folderLink>
</task>
</tasks>
编辑2 :如果我这样做
loadComplete : function()
{
var data = $grid.getCol('Details');
alert(data);
},
它会正确返回所有内容!
答案 0 :(得分:0)
loadComplete : function()
{
var data = $grid.getCol('Details', true);
},
这将返回具有rowIds的Details Cell中的内容。这解决了我被卡住的地方,但我仍然想知道为什么其他函数返回false。