2017-11-21 6 views
0

작성한 jqGrid 내에 데이터베이스의 데이터를 필사적으로 표시하려고했지만 필자는 실제로 어떻게 작동하는지 이해하지 못합니다.jqGrid에 데이터베이스 테이블 표시

나는 jqGrid에 대한 문서를 철저히 읽고 공식 웹 사이트의 데모를 적용하려했지만 그리드의 "데이터"옵션을 PHP/MySQL 또는 AJAX 스크립트로 바꾸는 간단한 방법을 찾을 수 없습니다. 여기 내 코드는 다음과 같습니다.

<script> 
     $(function(){ 
      $("#grid").jqGrid({ 
       colNames: ["ID", "Context", "IP", "Community", "Modèle", "Uptime", "Version Soft", "Version Patch", "Date d'ajout", "Date modif", "Refresh"], 
       colModel: [ 
        {name:'id', index:'id', width:60, sorttype:'int', align:'center'}, 
        {name:'context', index:'context', width:130, align:'center'}, 
        {name:'ip', index:'ip', width:150, align:'center'}, 
        {name:'community', index:'community', width:100, align:'center'}, 
        {name:'modele', index:'modele', width:80, align:'center'}, 
        {name:'uptime', index:'uptime', width:150, align:'center'}, 
        {name:'soft', index:'soft', width:150, align:'center'}, 
        {name:'patch', index:'patch', width:150, align:'center'}, 
        {name:'ajout', index:'ajout', width:100, sorttype:'date', align:'center'}, 
        {name:'modif', index:'modif', width:100, sorttype:'date', align:'center'}, 
        {name:'refresh', index:'refresh', width:70, align:'center', formatter:refresh_Button} 
       ], 
       data: [ 
        {id:"1",context:"LAB",ip:"192.168.xx.xx",community:"public",modele:"S57",ajout:"20-11-2017"} 
       ], 
       caption: "Equipements disponibles :", 
       sortname: 'id', 
       sortorder:"desc", 
       rowNum:20, 
       rowList:[20,40,60], 
       pager:'#yolo' 
      }); 
      function refresh_Button(cellvalue, options, rowobject){ 
       return '<button type="button" onclick="">Go</button>'; 

      } 

     }); 
    </script> 
</head> 

<body> 
<table id="grid"></table> 
<div id="yolo"></div> 
</body> 
</html> 

누구든지 이런 식으로 할 줄 알아요? 경우 사람들이 답을 알고 싶어 그냥에서

답변

0

, 당신은에 있습니다

  1. 이있는 jqGrid 옵션에서 이러한 매개 변수를 추가 :

URL을 "your_ajax_page.php"

mtype : "POST"// 또는 GET

데이터 유형 "JSON"

loadonce : "true"로

(
  • your_ajax_page.php를 만들고 기본적으로 공식있는 jqGrid 데모 웹 사이트에 "loadonce"데모를 복사

      현재 다운되고 있음). 당신이 당신의 데이터베이스 데이터와있는 jqGrid 행을 연결 한 후

    1. 는 "에코로 json_encode ($의 data_array)"

    2. 이 그것을해야 페이지의 하단에, 그것은 당신에게

    3. 도움을 희망 추가