JQuery FlexiGrid 与 Struts2
嗨,谁能告诉我下面的代码有什么问题吗...
我已经在 php 中配置了 Flexigrid,它工作正常,但是当我在 Struts 2 应用程序中尝试它时,它不会显示任何内容和加载图标不断要求等待... 我完全无法在 Flexigrid 中显示数据...我尝试了很多,但无法得到任何正确的解决方案... 但我可以在 FireBug 中看到服务器返回的 JSON 我的意思是以下 json 响应在 FireBug 中可见,但在 FlexiGrid 中不可见 ...以下是我的代码...请看一下代码并指出我的错误...非常感谢
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/candidtrack/web/theme/css/flexigrid/flexigrid.css"/>
<script type="text/javascript" src="/candidtrack/web/theme/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="/candidtrack/web/theme/lib/flexigrid.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#flex1").flexigrid
(
{
url: '/candidtrack/web/requirement/requirement!gridInJson',
dataType: 'json',
colModel : [
{display: 'reqId', name : 'reqId', width : 40, sortable : true, align: 'left'},
{display: 'reqTitle', name : 'reqTitle', width : 90, sortable : true, align: 'left'},
{display: 'Job Type', name : 'Job Type', width : 90, sortable : true, align: 'left'},
{display: 'Company', name : 'Company', width : 90, sortable : true, align: 'left'},
{display: 'Contact Person', name : 'Contact Person', width : 90, sortable : true, align: 'left'},
{display: 'Location', name : 'Location', width : 90, sortable : true, align: 'left'},
{display: 'Submission End Date', name : 'Submission End Date', width : 90, sortable : true, align: 'left'},
{display: 'Career Level', name : 'Career Level', width : 90, sortable : true, align: 'left'},
{display: 'Required Skills', name : 'Required Skills', width : 100, sortable : true, align: 'left'},
{display: 'Education Level', name : 'Education Level', width : 90, sortable : true, align: 'left'},
{display: 'Residence Status', name : 'Residence Status', width : 95, sortable : true, align: 'left'},
{display: 'Bill Rate', name : 'Bill Rate', width : 35, sortable : true, align: 'right'},
{display: 'Status', name : 'Status', width : 45, sortable : true, align: 'left'},
{display: 'Action', name : 'Action', width : 35, sortable : true, align: 'center'}
],
buttons : [
{separator: true},
{name: 'A', onpress: sortAlpha},
{name: 'B', onpress: sortAlpha},
{name: 'C', onpress: sortAlpha},
{name: 'D', onpress: sortAlpha},
{name: 'E', onpress: sortAlpha},
{name: 'F', onpress: sortAlpha},
{name: 'G', onpress: sortAlpha},
{name: 'H', onpress: sortAlpha},
{name: 'I', onpress: sortAlpha},
{name: 'J', onpress: sortAlpha},
{name: 'K', onpress: sortAlpha},
{name: 'L', onpress: sortAlpha},
{name: 'M', onpress: sortAlpha},
{name: 'N', onpress: sortAlpha},
{name: 'O', onpress: sortAlpha},
{name: 'P', onpress: sortAlpha},
{name: 'Q', onpress: sortAlpha},
{name: 'R', onpress: sortAlpha},
{name: 'S', onpress: sortAlpha},
{name: 'T', onpress: sortAlpha},
{name: 'U', onpress: sortAlpha},
{name: 'V', onpress: sortAlpha},
{name: 'W', onpress: sortAlpha},
{name: 'X', onpress: sortAlpha},
{name: 'Y', onpress: sortAlpha},
{name: 'Z', onpress: sortAlpha},
{name: '#', onpress: sortAlpha}
],
searchitems : [
{display: 'reqId', name : 'reqId'},
// {display: 'Name', name : 'name', isdefault: true}
],
sortname: "reqId",
sortorder: "asc",
usepager: true,
useRp: true,
rp: 10,
showTableToggleBtn: true,
width: 988,
height: 400
}
);
});
function sortAlpha(com)
{
jQuery('#flex1').flexOptions({newp:1, params:[{name:'letter_pressed', value: com},{name:'qtype',value:$('select[name=qtype]').val()}]});
jQuery("#flex1").flexReload();
}
function test(com,grid)
{
if (com=='Delete')
{
if($('.trSelected',grid).length>0){
if(confirm('Delete ' + $('.trSelected',grid).length + ' items?')){
var items = $('.trSelected',grid);
var itemlist ='';
for(i=0;i<items.length;i++){
itemlist+= items[i].id.substr(3)+",";
}
$.ajax({
type: "POST",
dataType: "json",
url: "/candidtrack/web/requirement/requirement!gridInJson",
data: "items="+itemlist,
success: function(data){
alert("Query: "+data.query+" - Total affected rows: "+data.total);
$("#flex1").flexReload();
}
});
}
} else {
return false;
}
}
else if (com=='Add')
{
alert('Add New Item Action');
}
}
</script>
</head>
<body >
<table align="center" id="flex1">
</table>
</body>
,服务器返回的 JSON 显示在 FireBug 上,但不能显示在 Flexigrid 中。是::
{
page:1 ,
total: 9,
rows: [
{reqId:'1',cell:['1','Title Req1111','Job-ContractToHire','Company 2','Frist Name mid Last','Location 2','2010-12-12','Career Level 2','Dot NetJava','Bachelor','TN Visa','1/Y']},
{reqId:'2',cell:['2','title ','Job-ContractToHire','Company 2','Salman 8 ItsMe','Location 2','2010-12-01','Career Level 1','Dot Net','','Green Card','234/H']},
{reqId:'3',cell:['3','t','Job-ContractToHire','Company 2','f m l','Location 3','2011-01-29','Career Level 1','','','Citizen','23/H']},
{reqId:'4',cell:['4','t','Job-ContractToHire','Company 2','f m l','Locaion 1','2011-01-11','Career Level 2','','','Green Card','23/H']},
{reqId:'5',cell:['5','t','Job-ContractToHire','Company 2','f m l','Locaion 1','2011-01-11','Career Level 2','','Bachelor','Green Card','23/H']},
{reqId:'7',cell:['7','t','Job-FullTime','comp4',' ','Location 2','2011-03-17','Career Level 2','Any Skill','Bachelor','Green Card','3/H']},
{reqId:'8',cell:['8','tt','Job-Contract','comp4',' ','Location 2','2011-03-23','Career Level 2','Dot Net','','Citizen','3/H']},
{reqId:'9',cell:['9','tt','Job-Contract','comp4',' ','Location 2','2011-03-23','Career Level 2','Dot Net','','Citizen','3/H']},
{reqId:'10',cell:['10','uuu','Job-Contract','comp4',' ','Location 2','2011-03-18','Career Level 1','Java','Bachelor','Citizen','12/H']}]
}
提前致谢
Hi can any one tell me whats wrong with the following code...
i have configured the Flexigrid in php it is working fine but when i tried it in Struts 2 application it doest display any thing and the loading icon continuously asking to wait...
I m totally unable to display the data in the Flexigrid... i tried a alot but could not get any proper solution...
But i can see the JSON returned by the server in FireBug i mean the following json response is visible in FireBug but not in FlexiGrid
...Following is my code... plz take a look at the code and point out my mistake... THANKS ALOT
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/candidtrack/web/theme/css/flexigrid/flexigrid.css"/>
<script type="text/javascript" src="/candidtrack/web/theme/lib/jquery/jquery.js"></script>
<script type="text/javascript" src="/candidtrack/web/theme/lib/flexigrid.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#flex1").flexigrid
(
{
url: '/candidtrack/web/requirement/requirement!gridInJson',
dataType: 'json',
colModel : [
{display: 'reqId', name : 'reqId', width : 40, sortable : true, align: 'left'},
{display: 'reqTitle', name : 'reqTitle', width : 90, sortable : true, align: 'left'},
{display: 'Job Type', name : 'Job Type', width : 90, sortable : true, align: 'left'},
{display: 'Company', name : 'Company', width : 90, sortable : true, align: 'left'},
{display: 'Contact Person', name : 'Contact Person', width : 90, sortable : true, align: 'left'},
{display: 'Location', name : 'Location', width : 90, sortable : true, align: 'left'},
{display: 'Submission End Date', name : 'Submission End Date', width : 90, sortable : true, align: 'left'},
{display: 'Career Level', name : 'Career Level', width : 90, sortable : true, align: 'left'},
{display: 'Required Skills', name : 'Required Skills', width : 100, sortable : true, align: 'left'},
{display: 'Education Level', name : 'Education Level', width : 90, sortable : true, align: 'left'},
{display: 'Residence Status', name : 'Residence Status', width : 95, sortable : true, align: 'left'},
{display: 'Bill Rate', name : 'Bill Rate', width : 35, sortable : true, align: 'right'},
{display: 'Status', name : 'Status', width : 45, sortable : true, align: 'left'},
{display: 'Action', name : 'Action', width : 35, sortable : true, align: 'center'}
],
buttons : [
{separator: true},
{name: 'A', onpress: sortAlpha},
{name: 'B', onpress: sortAlpha},
{name: 'C', onpress: sortAlpha},
{name: 'D', onpress: sortAlpha},
{name: 'E', onpress: sortAlpha},
{name: 'F', onpress: sortAlpha},
{name: 'G', onpress: sortAlpha},
{name: 'H', onpress: sortAlpha},
{name: 'I', onpress: sortAlpha},
{name: 'J', onpress: sortAlpha},
{name: 'K', onpress: sortAlpha},
{name: 'L', onpress: sortAlpha},
{name: 'M', onpress: sortAlpha},
{name: 'N', onpress: sortAlpha},
{name: 'O', onpress: sortAlpha},
{name: 'P', onpress: sortAlpha},
{name: 'Q', onpress: sortAlpha},
{name: 'R', onpress: sortAlpha},
{name: 'S', onpress: sortAlpha},
{name: 'T', onpress: sortAlpha},
{name: 'U', onpress: sortAlpha},
{name: 'V', onpress: sortAlpha},
{name: 'W', onpress: sortAlpha},
{name: 'X', onpress: sortAlpha},
{name: 'Y', onpress: sortAlpha},
{name: 'Z', onpress: sortAlpha},
{name: '#', onpress: sortAlpha}
],
searchitems : [
{display: 'reqId', name : 'reqId'},
// {display: 'Name', name : 'name', isdefault: true}
],
sortname: "reqId",
sortorder: "asc",
usepager: true,
useRp: true,
rp: 10,
showTableToggleBtn: true,
width: 988,
height: 400
}
);
});
function sortAlpha(com)
{
jQuery('#flex1').flexOptions({newp:1, params:[{name:'letter_pressed', value: com},{name:'qtype',value:$('select[name=qtype]').val()}]});
jQuery("#flex1").flexReload();
}
function test(com,grid)
{
if (com=='Delete')
{
if($('.trSelected',grid).length>0){
if(confirm('Delete ' + $('.trSelected',grid).length + ' items?')){
var items = $('.trSelected',grid);
var itemlist ='';
for(i=0;i<items.length;i++){
itemlist+= items[i].id.substr(3)+",";
}
$.ajax({
type: "POST",
dataType: "json",
url: "/candidtrack/web/requirement/requirement!gridInJson",
data: "items="+itemlist,
success: function(data){
alert("Query: "+data.query+" - Total affected rows: "+data.total);
$("#flex1").flexReload();
}
});
}
} else {
return false;
}
}
else if (com=='Add')
{
alert('Add New Item Action');
}
}
</script>
</head>
<body >
<table align="center" id="flex1">
</table>
</body>
and the JSON which is returned by server that is displayed on FireBug but could not in the Flexigrid. is::
{
page:1 ,
total: 9,
rows: [
{reqId:'1',cell:['1','Title Req1111','Job-ContractToHire','Company 2','Frist Name mid Last','Location 2','2010-12-12','Career Level 2','Dot NetJava','Bachelor','TN Visa','1/Y']},
{reqId:'2',cell:['2','title ','Job-ContractToHire','Company 2','Salman 8 ItsMe','Location 2','2010-12-01','Career Level 1','Dot Net','','Green Card','234/H']},
{reqId:'3',cell:['3','t','Job-ContractToHire','Company 2','f m l','Location 3','2011-01-29','Career Level 1','','','Citizen','23/H']},
{reqId:'4',cell:['4','t','Job-ContractToHire','Company 2','f m l','Locaion 1','2011-01-11','Career Level 2','','','Green Card','23/H']},
{reqId:'5',cell:['5','t','Job-ContractToHire','Company 2','f m l','Locaion 1','2011-01-11','Career Level 2','','Bachelor','Green Card','23/H']},
{reqId:'7',cell:['7','t','Job-FullTime','comp4',' ','Location 2','2011-03-17','Career Level 2','Any Skill','Bachelor','Green Card','3/H']},
{reqId:'8',cell:['8','tt','Job-Contract','comp4',' ','Location 2','2011-03-23','Career Level 2','Dot Net','','Citizen','3/H']},
{reqId:'9',cell:['9','tt','Job-Contract','comp4',' ','Location 2','2011-03-23','Career Level 2','Dot Net','','Citizen','3/H']},
{reqId:'10',cell:['10','uuu','Job-Contract','comp4',' ','Location 2','2011-03-18','Career Level 1','Java','Bachelor','Citizen','12/H']}]
}
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请也分享您的操作类代码。
希望以下是指正
将搜索项替换为以下代码
或需要在评论之前删除 ,
please share your action class code too.
I hope below is the correction
Replace search items with below code
or need to remove , just before comment