2011-04-23 75 views
0

嗨任何一個可以告訴我什麼是錯用下面的代碼...JQuery的FlexiGrid與Struts2的

我已經在PHP配置的Flexigrid它工作正常,但是當我在Struts 2的應用程序嘗試它,它利己顯示任何東西和加載圖標不斷要求等待... 我完全無法顯示Flexigrid中的數據...我嘗試了很多,但無法得到任何適當的解決方案... 但我可以看到JSON由FireBug中的服務器返回我的意思是在FireBug中可見的以下json響應,但不在FlexiGrid ...以下是我的代碼... plz看看代碼並指出我的錯誤...謝謝備註

<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不能在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']}] 
} 

由於提前

回答

0

也請分享你的動作類代碼。 我希望下面是修正 只是評論

之前更換搜索條目下面的代碼

searchitems : [   
     {display: 'reqId', name : 'reqId'} 
// {display: 'Name', name : 'name', isdefault: true} 
], 

或需要刪除,