Reputation: 7
jQuery(function(){
var year = jQuery("#historyQuery").val();
var projectCode = jQuery("#projectCode").val();
jQuery("#list").jqGrid({
hidegrid:false,
height:300,
pgbuttons:false,
pginput:false,
url:'index.php?option=com_projectdetails&view=details&task=ajaxdetails.getProjectDetails&format=xml',
// editurl:'index.php?option=com_cwmaintain&view=incharge&task=ajaxincharge.editcwmaintain&format=xml',
datatype: 'xml',
mtype: 'post',
colNames:['日期','凭证号','摘要','收入/拨出','支出/拨出','借还款'],
colModel :[
{name:'N3', index:'N3', width:110,sortable:false,editable:false},
{name:'N4', index:'N4', width:110,sortable:false,editable:true,editrules:{required:true}},
{name:'N5', index:'N5', width:110,sortable:false,editable:true,editrules:{required:true}},
{name:'N7', index:'N7', width:110,sortable:false,editable:true,editrules:{required:true}},
{name:'N6', index:'N6', width:110,sortable:false,editable:true,editrules:{required:true}},
{name:'N6', index:'N6', width:110,sortable:false,editable:true,editrules:{required:true}},
],
rowNum:20,
reccount:10,
viewrecords: true,
gridview: true,
pager: '#pager',
caption: '部门负责人' // jqgrid标题
});
jQuery("#list").navGrid('#pager',{edit:false,add:false,del:false,search:true,refresh:true});
});
I want to transmit the two paramaters named year and projectCode to the function of getProjectDetails($year,$projectCode)
, how can I do this?
Upvotes: 0
Views: 83
Reputation: 221997
If I understand you correctly you should add additional postData
option to jqGrid where you define properties of postData
as functions:
postData: {
year: function () { return $("#historyQuery").val(); },
projectCode: function () { return $("#projectCode").val(); }
}
In the case the current values from "#historyQuery"
and $("#projectCode")
will be get on every new request to the server. It's important to understand that year
and projectCode
will be not appended to the URL because you use mtype: 'post'
option. The parameters will be send in the body of the request in the same way like parameters page
, rows
, sidx
, sord
and _search
.
See the answer for more details.
Upvotes: 1
Reputation: 1225
Statically you can use postData
to add parameters to the request like
jQuery("#list").jqGrid({
...
postData:{year:year,projectCode:projectCode },
....
Dynamically you can use setGridParam
method and again use the postData as parameter.
Please refer to the documentation page
Upvotes: 1