2014-02-26 37 views
0

我一直在使用的jqGrid,使多用戶應用程序的多用戶的凍結(70個多人)。該電網工程完全在本地主機上,甚至在服務器上時,只有一個人在使用它,但只要有有幾個人登錄,除一個人以外,應用程序隨機停止加載每個人。當一個人完成他的動作而另一個人重新加載頁面時,情況恢復正常。 這裏是我的代碼: 我已經到處找,但似乎我有這個問題的唯一一個。 在此先感謝。的jqGrid上

$("#list").jqGrid({ 
    url: 'include/configacompte.php', 
    editurl:"include/editacompte.php", 
    datatype: "xml", 
    mtype: "GET", 
    postData:{idagenceco: "<?php echo $_SESSION['idAgence'] ?>" }, 
    colnames : [...] 
    pager: jQuery("#pager"), 
    rowNum: 100, 
    rowList: [100, 200, 300], 
    autowidth: true, 
    sortname: "numSemaine", 
    sortorder: "asc", 
    viewrecords: true, 
    gridview: true, 
    autoencode: true, 
    onSelectRow: function(id){ 
    if(id && id!==lastsel2){ 
     $('#list').jqGrid('restoreRow',lastsel2); 
     $('#list').jqGrid('editRow',id,true,'','','','',reload); 
     lastsel2=id; 

      } 
}, 
    multiboxonly:true, 
    multiselect: true, 
    loadonce : true, 
    scroll:1, 
    height:500, 
    ignoreCase:true, 
    caption: "Gestion des Acomptes"   

}); 

function reload() { 
    window.location.reload(); 
}; 


$("#list").jqGrid('filterToolbar',{stringResult: true,searchOperators : true,searchOnEnter:true}); 

$("#list").jqGrid('getGridParam','url'); 



$("#list").jqGrid('navGrid','#pager',{edit:false,add:false,refresh:false}, 
       {/* reloadAfterSubmit: true, closeAfterAdd: true, closeAfterEdit: true, closeAfterSubmit: true*/ }, // default settings for edit 
       {/*closeAfterAdd: true*/ }, // default settings for add 
       { url: 'include/editacompte.php', 
        onclickSubmit: function (options, postdata) { 
        alert('Enregistrement(s) supprimé(s)'); 
        return { myData: 'Hello'}; 
       } 
       }, // delete instead that del:false we need this 
       {seOnEscape: true, closeAfterSearch: true}, // search options 
       {} /* view parameters*/ 
       ); 




$("#list").jqGrid('inlineNav',"#pager",{addParams: { 
    useDefValues: true, 
    position :"first", 
    addRowParams:{keys:true,aftersavefunc:reload} 
    }}, 
{},// edit 
{}//add 
); 



$("#list").jqGrid('sortableRows'); 



}); 

configacompte.php

<?php 

//include the information needed for the connection to MySQL data base server. 
// we store here username, database and password 
include("dbconfig.php"); 
//include("phptest.php"); 

// to the url parameter are added 4 parameters as described in colModel 
// we should get these parameters to construct the needed query 
// Since we specify in the options of the grid that we will use a GET method 
// we should use the appropriate command to obtain the parameters. 
// In our case this is $_GET. If we specify that we want to use post 
// we should use $_POST. Maybe the better way is to use $_REQUEST, which 
// contain both the GET and POST variables. For more information refer to php   documentation. 
// Get the requested page. By default grid sets this to 1. 

$page = $_GET['page']; 

// get how many rows we want to have into the grid - rowNum parameter in the grid 
$limit = $_GET['rows']; 
//$limit = isset($_POST['rows'])? $_POST['rows']:100; 
// get index row - i.e. user click to sort. At first time sortname parameter - 
// after that the index from colModel 
$sidx =$_GET['sidx']; //$_REQUEST['sidx']; 

// sorting order - at first time sortorder 
$sord = $_GET['sord']; // $_GET['sord']; 
//$idagenceco = $_GET['idagenceco'];*/ 

$idagenceco=$_GET['idagenceco']; 
// if we not pass at first time index use the first column for the index or what you want 
if(!$sidx) $sidx =1; 


// connect to the MySQL database server 
$db = mysql_connect(DBHOST,DBUSER,DBPASSWD) or die("Connection Error: " . mysql_error()); 

// select the database 
mysql_select_db(DBNAME) or die("Error connecting to db."); 

// calculate the number of rows for the query. We need this for paging the result 


$result = mysql_query("SELECT COUNT(*) AS count FROM gestionacompte where idAgence=$idagenceco ORDER BY IdAcompte"); 
$row = mysql_fetch_array($result,MYSQL_ASSOC) or die(mysql_error()); 
$count = $row['count']; 


// calculate the total pages for the query 
if($count > 0) { 
      $total_pages = ceil($count/$limit); 
} else { 
      $total_pages = 0; 
} 

// if for some reasons the requested page is greater than the total 
// set the requested page to total page 
if ($page > $total_pages) $page=$total_pages; 

// calculate the starting position of the rows 
$start = $limit*$page - $limit; 

// if for some reasons start position is negative set it to 0 
// typical case is that the user type 0 for the requested page 
if($start <0) $start = 0; 

// the actual query for the grid data 
$SQL = "SELECT IdAcompte, numAgence, nomAcompte, prenomAcompte, numSemaine, societe, montantAcompte, typeReglement, dateAcompte, idAgence FROM gestionacompte where idAgence=$idagenceco ORDER BY $sidx"; 
$result = mysql_query($SQL) or die("Couldn't execute query.".mysql_error()); 


// we should set the appropriate header information. Do not forget this. 
header("Content-type: text/xml;charset=utf-8"); 

$s = "<?xml version='1.0' encoding='utf-8'?>"; 
$s .= "<rows>"; 
$s .= "<page>".$page."</page>"; 
$s .= "<total>".$total_pages."</total>"; 
$s .= "<records>".$count."</records>"; 


// be sure to put text data in CDATA 
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { 
$s .= "<row id='". $row['IdAcompte']."'>"; 
$s .= "<cell>". $row['IdAcompte']."</cell>"; 
$s .= "<cell>". $row['numSemaine']."</cell>"; 
$s .= "<cell>". $row['numAgence']."</cell>"; 
$s .= "<cell>". $row['nomAcompte']."</cell>"; 
$s .= "<cell>". $row['prenomAcompte']."</cell>"; 
$s .= "<cell>". $row['societe']."</cell>"; 
$s .= "<cell>". $row['montantAcompte']."</cell>"; 
$s .= "<cell>". $row['typeReglement']."</cell>"; 
$s .= "<cell>". $row['dateAcompte']."</cell>"; 
$s .= "<cell>". $row['idAgence']."</cell>"; 
$s .= "</row>"; 
} 
$s .= "</rows>"; 

echo $s; 

?> 
+0

我沒有PHP的知識。但只是想確保網址'網址:「包括在服務器部署時/ configacompte.php''是爲多個用戶工作的罰款。 –

+0

我已經編輯我的職務與configacompte.php的代碼。我怎麼知道它是否在多用戶工作?我不明白爲什麼它不起作用。謝謝你的回覆,它仍然給我一個地方看。 – Oriana

回答

0

Im相當肯定它通過此舉引起>>

onSelectRow: function(id){ 
    if(id && id!==lastsel2){ 
     $('#list').jqGrid('restoreRow',lastsel2); 
     $('#list').jqGrid('editRow',id,true,'','','','',reload); 
     lastsel2=id; 

      } 
} 

和inlineEditing它自身。

我建議你使用cellEditing。

+0

我也會試着去研究一下。謝謝 – Oriana