簡體   English   中英

將jqGrid與ArrayData一起使用,並使用添加,編輯和刪除按鈕

[英]Using jqGrid with ArrayData and using the add, edit and delete buttons

我正在嘗試為簡單的表格輸入獲取基本的數據網格。 服務器將發送列信息並呈現相應的表,以供用戶輸入記錄,然后他們將其回發到服務器。

我正在嘗試讓jqGrid將數據保存為ArrayData而不使用數據庫,因此我完成了以下代碼對其進行測試:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Grid</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/custom-theme/jquery-ui-1.7.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<style>
html, body {
    margin: 0;
    padding: 0;
    font-size: 75%;
}
</style>

<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>

<script type="text/javascript">
jQuery(document).ready(function(){ 
  jQuery("#list").jqGrid({
    datatype: "local",
    colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
    colModel :[ 
      {name:'invid', index:'invid', width:55, editable:true,editoptions:{size:10}}, 
      {name:'invdate', index:'invdate', width:90, editable:true}, 
      {name:'amount', index:'amount', width:80, align:'right', editable:true}, 
      {name:'tax', index:'tax', width:80, align:'right', editable:true}, 
      {name:'total', index:'total', width:80, align:'right', editable:true}, 
      {name:'note', index:'note', width:150, sortable:false, editable:true} 
    ],
    pager: '#pager',
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'invid',
    sortorder: 'desc',
    viewrecords: true,
    caption: 'My first grid',


  }).navGrid('#pager', {add:true, del:true});
  myfirstrow = {
  invid:"1",
  invdate:"2007-10-01",
  note:"note",
  amount:"200.00",
  tax:"10.00",
  total:"210.00"}
  jQuery("#list").addRowData("1", myfirstrow);
});
</script>

</head>
<body>
<table id="list"></table> 
<div id="pager"></div> 
</body>
</html>

單擊“添加行”並填寫表格后,選擇“提交”時會彈出“沒有URI設置消息”,有人知道我該如何解決這個問題,這樣我就可以在客戶端輸入表數據,然后發送所有數據立刻回到服務器?

謝謝

我認為您收到的消息表明jqGrid需要URI集,因此它知道將數據發送到哪里。 您需要添加“ url”或“ editurl”設置,並將其值設置為將數據發布到的URL。 jqGrid將使用AJAX發布該數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM