Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过内联编辑创建jqgrid_Jqgrid - Fatal编程技术网

通过内联编辑创建jqgrid

通过内联编辑创建jqgrid,jqgrid,Jqgrid,使用版本4.4.1 看看这里的例子 尝试复制示例,但无法获得内联行编辑,也无法向列添加复选框 我希望用户能够单击一行,单击“编辑”按钮,该行将变得可编辑 我也尝试了下面的代码片段 jQuery(文档).ready(函数(){ var lastsel2 jQuery(“#rowed5”).jqGrid({ 数据类型:“本地”, 身高:250, colNames:['ID Number','Name','Stock','Ship via','Notes'], colModel:[ {名称:'id

使用版本
4.4.1

看看这里的例子

尝试复制示例,但无法获得内联行编辑,也无法向列添加复选框

我希望用户能够单击一行,单击“编辑”按钮,该行将变得可编辑

我也尝试了下面的代码片段


jQuery(文档).ready(函数(){
var lastsel2
jQuery(“#rowed5”).jqGrid({
数据类型:“本地”,
身高:250,
colNames:['ID Number','Name','Stock','Ship via','Notes'],
colModel:[
{名称:'id',索引:'id',宽度:90,排序类型:“int”,可编辑:true},
{name:'name',index:'name',width:150,edit:true,editoptions:{size:'20',maxlength:'30'},
{名称:'stock',索引:'stock',宽度:60,可编辑:true,edittype:“复选框”,editoptions:{value:“是:否”},
{name:'ship',index:'ship',width:90,edittype:'select',formatter:'select',editoptions:{value:'FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX},
{名称:'note',索引:'note',宽度:200,可排序:false,可编辑:true,edittype:'textarea',editoptions:{行:“2”,列:“10”}
],
OnSetrow:功能(id){
if(id&&id!==lastsel2){
jQuery(“#rowed5”).restoreRow(lastsel2);
jQuery('#rowed5').editRow(id,true);
lastsel2=id;
}
},
editurl:“server.php”,
标题:“输入类型”
});
变量mydata2=[
{id:“12345”,名称:“台式计算机”,备注:“备注”,库存:“是”,发货:“FE”},
{id:“23456”,名称:“笔记本电脑”,注释:“长文本”,股票:“是”,船舶:“在”},
{id:“34567”,名称:“液晶显示器”,注:“注3”,库存:“是”,发货:“TN”},
{id:“45678”,姓名:“发言者”,注:“注”,库存:“否”,船舶:“AR”},
{id:“56789”,名称:“激光打印机”,注:“注2”,库存:“是”,发货:“FE”},
{id:“67890”,名称:“Play Station”,注释:“note3”,股票:“No”,船舶:“FE”},
{id:“76543”,名称:“移动电话”,注释:“注释”,股票:“是”,船舶:“AR”},
{id:“87654”,名称:“服务器”,注:“注2”,库存:“是”,发货:“TN”},
{id:“98765”,名称:“矩阵打印机”,注:“注3”,库存:“否”,发货:“FE”}
];

对于(var i=0;i您得到了什么错误?jqGrid文档和示例有点不稳定。您尝试过jqGrid的更高版本吗?我们使用了4.6.0和几个月前的校样内联编辑。最终成功。:)控制台中没有错误,只是行未处于编辑状态。如果我注释掉restorerow,我将启用多行编辑。我不想使用restore row,但只希望有一行可编辑。更新的代码显示编辑按钮可在选择行时进行编辑
<head>
<script type="text/javascript">
jQuery(document).ready(function(){ 
  var lastsel2
  jQuery("#rowed5").jqGrid({        
    datatype: "local",
    height: 250,
    colNames:['ID Number','Name', 'Stock', 'Ship via','Notes'],
    colModel:[
      {name:'id',index:'id', width:90, sorttype:"int", editable: true},
      {name:'name',index:'name', width:150,editable: true, editoptions:{size:"20",maxlength:"30"}},
      {name:'stock',index:'stock', width:60, editable: true, edittype:"checkbox",editoptions: {value:"Yes:No"}},
      {name:'ship',index:'ship', width:90, editable: true, edittype:"select",formatter:'select', editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},                       
      {name:'note',index:'note', width:200, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"10"}}                      
              ],
    onSelectRow: function(id){
      if(id && id!==lastsel2){
        jQuery('#rowed5').restoreRow(lastsel2);
        jQuery('#rowed5').editRow(id,true);
          lastsel2=id;
      }
    },
    editurl: "server.php",
    caption: "Input Types"
  });
  var mydata2 = [
    {id:"12345",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FE"},
    {id:"23456",name:"Laptop",note:"Long text ",stock:"Yes",ship:"IN"},
    {id:"34567",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TN"},
    {id:"45678",name:"Speakers",note:"note",stock:"No",ship:"AR"},
    {id:"56789",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FE"},
    {id:"67890",name:"Play Station",note:"note3",stock:"No", ship:"FE"},
    {id:"76543",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"AR"},
    {id:"87654",name:"Server",note:"note2",stock:"Yes",ship:"TN"},
    {id:"98765",name:"Matrix Printer",note:"note3",stock:"No", ship:"FE"}
    ];
  for(var i=0;i<mydata2.length;i++)
    jQuery("#rowed5").addRowData(mydata2[i].id,mydata2[i]);
});
</script>
</head>
<body>
<table id="rowed5" class="scroll"></table>
</body>
</html>
jQuery(document).ready(function(){ 
  var currentID,prevID
  jQuery("#rowed5").jqGrid({        
    datatype: "local",
    height: 300,
    colNames:['ID Number','Name', 'Stock', 'Ship via','Notes'],
    colModel:[
      {name:'id',index:'id', width:90, sorttype:"int", editable: true},
      {name:'name',index:'name', width:150,editable: true, editoptions:{size:"20",maxlength:"30"}},
      {name:'stock',index:'stock', width:60, editable: true, edittype:"checkbox",editoptions: {value:"Yes:No"}},
      {name:'ship',index:'ship', width:90, editable: true, edittype:"select",formatter:'select', editoptions:{value:"FE:FedEx;IN:InTime;TN:TNT;AR:ARAMEX"}},                       
      {name:'note',index:'note', width:200, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"2",cols:"10"}}                      
              ],
  onSelectRow: function(id){
      if(id && id!==prevID){

          currentID=id;
      }
    },
    editurl: "server.php",
    caption: "Input Types",
      pager: '#pager',
  })
  .navGrid("#pager", {edit:false, add:false, del:false,search:false })
  .navButtonAdd('#pager',{
   caption:"EDIT", 

   onClickButton: function(){ 

        if(currentID && currentID!==prevID){
        jQuery('#rowed5').editRow(prevID,false);
        jQuery('#rowed5').editRow(currentID,true);
        prevID = currentID;
        }

   }, 
   position:"last"
});

  var mydata2 = [
    {id:"12345",name:"Desktop Computer",note:"note",stock:"Yes",ship:"FE"},
    {id:"23456",name:"Laptop",note:"Long text ",stock:"Yes",ship:"IN"},
    {id:"34567",name:"LCD Monitor",note:"note3",stock:"Yes",ship:"TN"},
    {id:"45678",name:"Speakers",note:"note",stock:"No",ship:"AR"},
    {id:"56789",name:"Laser Printer",note:"note2",stock:"Yes",ship:"FE"},
    {id:"67890",name:"Play Station",note:"note3",stock:"No", ship:"FE"},
    {id:"76543",name:"Mobile Telephone",note:"note",stock:"Yes",ship:"AR"},
    {id:"87654",name:"Server",note:"note2",stock:"Yes",ship:"TN"},
    {id:"98765",name:"Matrix Printer",note:"note3",stock:"No", ship:"FE"}
    ];
  for(var i=0;i<mydata2.length;i++)
    jQuery("#rowed5").addRowData(mydata2[i].id,mydata2[i]);
});