组合框中选定的值在第一次打开编辑表单时未标记

发布于 2024-12-08 17:31:38 字数 10428 浏览 0 评论 0 原文

我正在使用 jqgrid 4,并且我从 stackoverflow,尤其是 Oleg 那里得到了很多帮助。

问题是,当我第一次打开编辑表单时,组合框不显示所选值。 这种情况仅发生在第一次打开编辑表单时。 第一次后,组合框将在编辑表单中设置为正确的值。 我使用过此页面中的内容: jqgrid 在编辑框中选择下拉选项值不正确,但问题仍然存在。

我改变了奥列格提议的所有事情。

我提到的第一个问题仍然存在。此外,除非我先按另一个字段,否则表单第一个字段中的日期选择器不会出现。

我的更新代码是

html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
    <title>Grid</title>
    <?php 
        session_start(); 
        include("showprogram.php"); 
    ?>
    <link rel="stylesheet" type="text/css" media="screen" href="src/css/jquery-ui-1.8.1.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="src/css/ui.jqgrid.css" />
    <script type='text/JavaScript' src='Scripts/calendar.js'></script>
    <!-- <script type='Text/JavaScript' src='scw.js'></script> -->
    <script src="Scripts/jquery.js" type="text/javascript"></script>
    <script src="Scripts/jquery.blockUI.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>
    <script src="js/jquery.layout.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 src="js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
    <style type="text/css">
    #list1 {
        font-size : 12px 
    }   

    body {z-index: 1000}
    </style>        
    <script type='text/JavaScript'>
    function showprogram () {
        document.all.Calculation.style.visibility = "visible";  
        try {
            ShowSchedule('#list1', '#pager1');

        } catch (e) {
            alert("An exception occurred while fetching the schedule. Error name: " + e.name + ". Error message: " + e.message);
        }
    }
    </script>
</head>
<body>
    <div id="grid" style="display:inline;">
    <table id="list1" class="scroll" cellpadding="0" cellspacing="0"></table> 
    <div id="pager1" class="scroll" style="text-align:center;"></div>
    </div>
</body>

dataform 是:

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if(!$sidx) $sidx =1;
// connect to the database
include ('../library/opendb.php');
$result = mysql_query("SELECT COUNT(*) AS count FROM customers ");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count >0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;

$start = $limit*$page - $limit; // do not put $limit*($page - 1) 

$SQL = "SELECT ID as id,Day AS Day, CustomerName AS name
       FROM customers";

$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) 
{
header("Content-type: application/xhtml+xml;charset=utf-8");
}
else
{
header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";
echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>" . $total_pages . "</total>";
echo "<records>".$count."</records>"; // be sure to put text data in CDATA

while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<row id='". $row[id]."'>";
echo "<cell>". $row[id]."</cell>";
echo "<cell>". $row[Day]."</cell>";
echo "<cell>". iconv("ISO-8859-7", "UTF-8", $row[name])."</cell>";

echo "<cell> Is this a button?<input type='button' value='E' onload=\"alert('ok');\"/>        </cell>";
echo "</row>";
} 
echo "</rows>"; 

include ('../library/closedb.php'); 

add.php 是

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
$oper = $_POST['oper'];
if(!$sidx) $sidx =1;
$Day = $_POST['Day'];
$name = $_POST['name'];

include ('../library/opendb.php');      
//Set at the right position 
        $name=$name+1;

if($oper == 'add') 

{   

$sql="INSERT INTO Customers (
              Day, 
              CustomerName VALUES ( 
      '".$Day."',
      '".$name."')";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

elseif($oper == 'del') 

{
$id = $_POST['id'];
$id=mysql_real_escape_string($id);

$sql="DELETE FROM customers 
    WHERE ID=
      '".$id."'";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

elseif($oper == 'edit') 
{
        $id = $_POST['id'];
        $id=mysql_real_escape_string($id);      
        $sql="UPDATE customers SET 
                        Day = '".$Hmera."', 
                        CustomerName = '".$name."'
                        WHERE ID = '".$id."'";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

showprogram.php:

function getDatacustomer()
{
include ('../library/opendb.php');
$SQL = "SELECT CustomerName FROM customers ORDER BY CustomerID ;";
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$count = mysql_num_rows($result);
include ('../library/closedb.php');
$value="";
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
if ($i!=($count-1)){
$value=$value.''.$i.':'. $row[CustomerName].';';}
else
{$value=$value.''.$i.':'. $row[CustomerName].'';}
$i=$i+1;
}
$value='value:"'.$value.'"';
return $value;
}
?>
<script type='text/JavaScript'>
function ShowSchedule(list, pager) {

jQuery().ready(function (){ 
jQuery(list).jqGrid({
    url:Url, 
    datatype: "xml",
    height: "auto",
    colNames:['id','Day','name'],
    colModel:[
    {name:'id',index:'id', width:40, align:'right', editable:false, editoptions:{readonly:true,size:10}},
    {name:'Day',index:'Day', width:70, align:'right', editable:true, sorttype: 'date', editrules:{date:true},
    editoptions:{dataInit:function(elem){setTimeout(function()
                {$(elem).datepicker({dateFormat:"yy-mm-dd"});},100);}}},
    {name:'name',index:'name', width:120, align:'right', editable:true, edittype:'select',editoptions:{<?php echo getDatacustomer() ?>}},
    ],
    rowNum:30,
    rowList:[10,20,30],
    pager: pager,
    sortname: 'Day',
    viewrecords: true,
    sortorder: "asc",
    loadonce: true,
    shrink: true,
    //toppager: true, for toppage pager 
    editurl:'add.php',
    caption:"Grid",     
    forceFit : true
    });

    jQuery(list).jqGrid('navGrid',pager,{edit:true,add:true,del:true,search:false,view:true, reload:true},
    {width:600,height:"auto",
    reloadAfterSubmit:true,
    closeAfterEdit: true,
    recreateForm: true, 
    onClose: function() {jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');},
    beforeShowForm: function(form) {
              var dlgDiv =  $("#editmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "260 px";
              dlgDiv[0].style.left = "600 px";
            }
    },
    {width:600,height:"auto",reloadAfterSubmit:true,closeAfterAdd: true,recreateForm: true, onClose: function() {
        jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');},beforeShowForm: function(form) {
              var dlgDiv =  $("#editmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "260 px";
              dlgDiv[0].style.left = "600 px";
            }
    },
    {width:600,height:"auto",reloadAfterSubmit:true,recreateForm: true}, 
    {height:280,reloadAfterSubmit:true}, 
    {width:650,height:"auto",reloadAfterSubmit:true,recreateForm: true, beforeShowForm: function(form) {
              var dlgDiv =  $("#viewmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "100 px";
              dlgDiv[0].style.left = "600 px";
            }},
    {});
    jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');
    });
}

我想要在数据库中的网格中的表格如下:

id      Day       CustomerName

1    2011-09-09      John

请帮忙!

I am using jqgrid 4 and i have got a lot of help from stackoverflow and especially Oleg.

The problem is that when i open my edit form for the first time the comboboxes do not show the selected values.
And this happen only in the first open of the edit form.
After the first time the comboboxes are set to the right value in the edit form.
I have used things from this page : jqgrid incorrect select drop down option values in edit box but problem still exists.

I changed all things Oleg proposed.

The first problem that i mentioned still exists. Moreover the datepicker in the first field of the form does not appear until i press in a another field first.

My update code is

the html is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7">
    <title>Grid</title>
    <?php 
        session_start(); 
        include("showprogram.php"); 
    ?>
    <link rel="stylesheet" type="text/css" media="screen" href="src/css/jquery-ui-1.8.1.custom.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="src/css/ui.jqgrid.css" />
    <script type='text/JavaScript' src='Scripts/calendar.js'></script>
    <!-- <script type='Text/JavaScript' src='scw.js'></script> -->
    <script src="Scripts/jquery.js" type="text/javascript"></script>
    <script src="Scripts/jquery.blockUI.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script>
    <script src="js/jquery.layout.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 src="js/jquery-ui-timepicker-addon.js" type="text/javascript"></script>
    <style type="text/css">
    #list1 {
        font-size : 12px 
    }   

    body {z-index: 1000}
    </style>        
    <script type='text/JavaScript'>
    function showprogram () {
        document.all.Calculation.style.visibility = "visible";  
        try {
            ShowSchedule('#list1', '#pager1');

        } catch (e) {
            alert("An exception occurred while fetching the schedule. Error name: " + e.name + ". Error message: " + e.message);
        }
    }
    </script>
</head>
<body>
    <div id="grid" style="display:inline;">
    <table id="list1" class="scroll" cellpadding="0" cellspacing="0"></table> 
    <div id="pager1" class="scroll" style="text-align:center;"></div>
    </div>
</body>

and dataform is:

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
if(!$sidx) $sidx =1;
// connect to the database
include ('../library/opendb.php');
$result = mysql_query("SELECT COUNT(*) AS count FROM customers ");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count >0 ) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;

$start = $limit*$page - $limit; // do not put $limit*($page - 1) 

$SQL = "SELECT ID as id,Day AS Day, CustomerName AS name
       FROM customers";

$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());

if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) 
{
header("Content-type: application/xhtml+xml;charset=utf-8");
}
else
{
header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";
echo "<rows>";
echo "<page>".$page."</page>";
echo "<total>" . $total_pages . "</total>";
echo "<records>".$count."</records>"; // be sure to put text data in CDATA

while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<row id='". $row[id]."'>";
echo "<cell>". $row[id]."</cell>";
echo "<cell>". $row[Day]."</cell>";
echo "<cell>". iconv("ISO-8859-7", "UTF-8", $row[name])."</cell>";

echo "<cell> Is this a button?<input type='button' value='E' onload=\"alert('ok');\"/>        </cell>";
echo "</row>";
} 
echo "</rows>"; 

include ('../library/closedb.php'); 

and the add.php is

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction
$oper = $_POST['oper'];
if(!$sidx) $sidx =1;
$Day = $_POST['Day'];
$name = $_POST['name'];

include ('../library/opendb.php');      
//Set at the right position 
        $name=$name+1;

if($oper == 'add') 

{   

$sql="INSERT INTO Customers (
              Day, 
              CustomerName VALUES ( 
      '".$Day."',
      '".$name."')";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

elseif($oper == 'del') 

{
$id = $_POST['id'];
$id=mysql_real_escape_string($id);

$sql="DELETE FROM customers 
    WHERE ID=
      '".$id."'";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

elseif($oper == 'edit') 
{
        $id = $_POST['id'];
        $id=mysql_real_escape_string($id);      
        $sql="UPDATE customers SET 
                        Day = '".$Hmera."', 
                        CustomerName = '".$name."'
                        WHERE ID = '".$id."'";
echo $sql;
$result = mysql_query($sql) or die (_ERROR26.":".mysql_error());
include ('../library/closedb.php');
}

and showprogram.php:

function getDatacustomer()
{
include ('../library/opendb.php');
$SQL = "SELECT CustomerName FROM customers ORDER BY CustomerID ;";
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
$count = mysql_num_rows($result);
include ('../library/closedb.php');
$value="";
$i=0;
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
if ($i!=($count-1)){
$value=$value.''.$i.':'. $row[CustomerName].';';}
else
{$value=$value.''.$i.':'. $row[CustomerName].'';}
$i=$i+1;
}
$value='value:"'.$value.'"';
return $value;
}
?>
<script type='text/JavaScript'>
function ShowSchedule(list, pager) {

jQuery().ready(function (){ 
jQuery(list).jqGrid({
    url:Url, 
    datatype: "xml",
    height: "auto",
    colNames:['id','Day','name'],
    colModel:[
    {name:'id',index:'id', width:40, align:'right', editable:false, editoptions:{readonly:true,size:10}},
    {name:'Day',index:'Day', width:70, align:'right', editable:true, sorttype: 'date', editrules:{date:true},
    editoptions:{dataInit:function(elem){setTimeout(function()
                {$(elem).datepicker({dateFormat:"yy-mm-dd"});},100);}}},
    {name:'name',index:'name', width:120, align:'right', editable:true, edittype:'select',editoptions:{<?php echo getDatacustomer() ?>}},
    ],
    rowNum:30,
    rowList:[10,20,30],
    pager: pager,
    sortname: 'Day',
    viewrecords: true,
    sortorder: "asc",
    loadonce: true,
    shrink: true,
    //toppager: true, for toppage pager 
    editurl:'add.php',
    caption:"Grid",     
    forceFit : true
    });

    jQuery(list).jqGrid('navGrid',pager,{edit:true,add:true,del:true,search:false,view:true, reload:true},
    {width:600,height:"auto",
    reloadAfterSubmit:true,
    closeAfterEdit: true,
    recreateForm: true, 
    onClose: function() {jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');},
    beforeShowForm: function(form) {
              var dlgDiv =  $("#editmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "260 px";
              dlgDiv[0].style.left = "600 px";
            }
    },
    {width:600,height:"auto",reloadAfterSubmit:true,closeAfterAdd: true,recreateForm: true, onClose: function() {
        jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');},beforeShowForm: function(form) {
              var dlgDiv =  $("#editmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "260 px";
              dlgDiv[0].style.left = "600 px";
            }
    },
    {width:600,height:"auto",reloadAfterSubmit:true,recreateForm: true}, 
    {height:280,reloadAfterSubmit:true}, 
    {width:650,height:"auto",reloadAfterSubmit:true,recreateForm: true, beforeShowForm: function(form) {
              var dlgDiv =  $("#viewmod" + jQuery(list)[0].id);
              var parentDiv = dlgDiv.parent(); // div#gbox_list
              var dlgWidth = dlgDiv.width();
              var parentWidth = parentDiv.width();
              var dlgHeight = dlgDiv.height();
              var parentHeight = parentDiv.height();
              // TODO: change parentWidth and parentHeight in case of the grid
                   // is larger as the browser window
              dlgDiv[0].style.top = "100 px";
              dlgDiv[0].style.left = "600 px";
            }},
    {});
    jQuery(list).jqGrid('setGridParam',{datatype:'xml', url:Url}).trigger('reloadGrid');
    });
}

The table i want in the grid from the database is like:

id      Day       CustomerName

1    2011-09-09      John

Please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

流年里的时光 2024-12-15 17:31:38

你的代码有太多错误。我建议您将您的代码与我的第一个网格<中的代码进行比较/a> jqGrid 文档的一部分。我只指出其中的一些错误,因为所有错误的列表太长:

  • 您必须包含 行作为生成您的 HTML 文件的第一行PHP 文件。最简单的形式是 HTML5:。当前您使用 jQuery UI 和 jqGrid 不支持的 怪异模式。此外,您当前在 之前包含 showprogram.php 事件。
  • 您在不同版本(最小化和未最小化)、完整代码和相同代码的一部分等中多次包含某些 JavaScript 或 CSS 文件。例如,如果您包含 jquery-ui-1.8.1.custom.css,则不需要包含 ui.datepicker.css。如果您包含 ui.jqgrid.css,则不需要包含 jqModal.css。包含 jquery.jsjquery-1.3.2.min.js 是下一个错误。包括ui.datepicker.jsjquery-ui-1.8.1.custom.min.jsjquery.ui.datetimepicker.min.js > 而不是只有一个 jquery-ui-1.8.1.custom.min.js 是下一个错误。如果您包含 jquery.jqGrid.min.js ,则包含同一代码的非最小化部分 grid.common.js 是错误的,... jqDnR.js。我可以继续...
  • 您应该仅在 jQuery(document).ready(function ( ) {...}); (使用旧样式的 jQuery().ready(function (){...}); 或超出块是错误的)。
  • 设置 jqGrid 参数并调用 jQuery(list).trigger("reloadGrid") 创建网格之前(在 jQuery(list).jqGrid({. ..});) 是错误的。
  • 代码 jQuery(list).jqGrid({...}); 创建网格。它创建许多内部结构并创建网格的许多 HTML 元素,如标题、列标题、分页器等。 网格只能创建一次。如果您想在网格中重新加载数据,您应该使用jQuery(list).trigger('reloadGrid')。在您当前的代码中,例如在 onClose 事件处理程序中,您只需调用 ShowSchedule ,它将尝试再次创建网格,这是错误的。

因此,您应该检查您的填充代码并重新设计如何在端口中划分代码。我可以重复
上面的错误列表并不完整。您必须仔细检查代码并重写其许多部分。

已更新:您修改的代码仍然是 PHP 代码和 JavaScript 代码的混合体。我自己不使用 PHP,但我认为您在选择组合框中的项目时出现的问题只是因为混合而存在。

代码中唯一的语法错误是在 colModel 定义末尾使用尾随逗号(,] 是非法的)。如果我只是将您的代码与一些简单的 XML 输入和 的一些简单结果一起使用(我使用 value:'John:John;Bob:Bob ')代码的工作原理请参见演示

更好的办法是将 JavaScript 代码与 PHP 代码明确分开。我建议您使用 dataUrl 属性>编辑选项。在这种情况下,应该生成 PHP 代码的相应部分,

<select><option value='John'>John</option><option value='Bob'>Bob</option></select>

而不是 value:"John:John;Bob:Bob"

该选项应该可以解决您的问题。

ajaxEditOptions: {cache: false}

更新2:如果我正确理解您当前的问题,

Your code have too many errors. I recommend you to compare your code with the code from My First Grid part of jqGrid documentation. I point only on some from there because the list of all errors will be too long:

  • You have to include <!DOCUMENT ...> line as the first line of your HTML file which generate your PHP file. The simplest form has HTML5: <!DOCUMENT html>. Currently you use quirks mode which is not supported by jQuery UI and jqGrid. Moreover you include currently showprogram.php event before <html>.
  • You include some JavaScript or CSS files many times in different versions (minimized and not minimized), full code and a part of the same code and so on. If you include for example jquery-ui-1.8.1.custom.css you don't need include ui.datepicker.css. If you include ui.jqgrid.css you don't need include jqModal.css. Including both jquery.js and jquery-1.3.2.min.js is the next error. Including ui.datepicker.js, jquery-ui-1.8.1.custom.min.js and jquery.ui.datetimepicker.min.js instead of just one jquery-ui-1.8.1.custom.min.js is the next error. If you includes jquery.jqGrid.min.js it would be wrong to include non-minimized parts of the same code grid.common.js, ... jqDnR.js. I can continue...
  • You should call the methods like jQuery(list).setGridParam and so on only inside of jQuery(document).ready(function () {...}); (the usage of old styled jQuery().ready(function (){...}); or out of the block is wrong).
  • Setting jqGrid parameter and calling jQuery(list).trigger("reloadGrid") before the grid will be created (before jQuery(list).jqGrid({...});) is wrong.
  • The code jQuery(list).jqGrid({...}); create the grid. It create many internal structures and create many HTML elements of the grid like title, column headers, pager and so on. The grid should be created only once. If you want to reload the data in the grid you should use jQuery(list).trigger('reloadGrid'). In your current code, for example in the onClose event handler you just call ShowSchedule which will try to create the grid one more time, which is wrong.

So you should examine your fill code and redesign how you divide the code in ports. I can repeat
that the above list of errors is not full. You have to examine your code vary careful and rewrite many its parts.

UPDATED: You modified code are still a mix from PHP code and JavaScript code. I don't use PHP myself, but I suppose that your problem with selection of the items in the comboboxes exist only because of the mix.

The only syntax error in your code is the usage of trailing commas at the end of colModel definition (,] is illegal). If I just use your code with some simple XML input and some simple result of <?php echo getDatacustomer() ?> (I use value:'John:John;Bob:Bob') the code works see the demo.

More better would be to make clear separation of JavaScript code from the PHP code. I would recommend you to use dataUrl property of editoptions. In the case the corresponding part of PHP code should generate

<select><option value='John'>John</option><option value='Bob'>Bob</option></select>

instead of value:"John:John;Bob:Bob".

UPDATED 2: The option

ajaxEditOptions: {cache: false}

should solve your problem if I understand your current problem correctly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文