jqgrid dataUrl函数代码段有问题

having trouble with jqgrid dataUrl function code segment(jqgrid dataUrl函数代码段有问题)
本文介绍了jqgrid dataUrl函数代码段有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要拥有当前选择的行 id 才能构建一个 JSON 字符串,该字符串将传递给 php 脚本以创建选择,因此我将脚本引用和代码包含在一个函数中.

I need to have the currently selected row id in order to build a JSON string that will be passed to a php script in order to create a select, so I enclosed the script reference and code in a function.

但是,这样做会产生 NetworkError: 403 Forbidden 错误.

However, doing so creates a NetworkError: 403 Forbidden error.

这里是代码段:

editoptions:{dataUrl:function(){
var row_id   = $('#tab3-grid').getGridParam('selrow');
var jsondata = JSON.stringify({"cu.STID": $('#tab3-grid').jqGrid('getCell', row_id, 'cu.STID'),
                               "wv.SVID": $('#tab3-grid').jqGrid('getCell', row_id, 'wv.SVID')});

return 'php/items-se-script.php?data='+jsondata;
},

有人知道怎么回事吗?

更新:

{name:'it.PRID', index:'it.PRID', hidden: true, editable:true,  edittype:'select',
editoptions:{dataUrl:'php/items-se-script.php', defaultValue:'26', dataEvents:[{type:'change',fn:function(e){$('input#ip\.Item').val($('option:selected', this).text());}}]},
formoptions:{label:'Item', elmprefix:'* '},
editrules:{edithidden:true, required:true}},

{name:'ip.Item', index:'ip.Item', hidden: true, sortable: true, editable:false, edittype:'text', editoptions:{readonly:true,size:20}, formoptions:{rowpos: 50, label:'Item'}, editrules:{required:true}}

],

ajaxSelectOptions: {
   type:'POST',
   data: {
      data: function () {
         var row_id = $('#tab3-grid').getGridParam('selrow');
         return JSON.stringify({
            "cu.STID": $('#tab3-grid').jqGrid('getCell', row_id, 'cu.STID'),
            "wv.SVID": $('#tab3-grid').jqGrid('getCell', row_id, 'wv.SVID')
         });
      }
   }
},

url:    'php/workordertab-script.php',
editurl:'php/workordertab-script.php',

推荐答案

属性 dataUrl 不能是函数.如果您需要在构建选择期间向服务器发送任何其他信息,您可以使用 ajaxSelectOptions 选项,就像我在 这里.在您的情况下,它将与以下内容有关:

The property dataUrl can't be a function. If you need to send any additional information to the server during building of select you can use ajaxSelectOptions option like I described as here. In your case it will be about the following:

var $myGrid = $('#tab3-grid');
$myGrid.jqGrid({
    // ... here all you current parameters which includes
    //     editoptions: { dataUrl: 'php/items-se-script.php' }
    // for the corresponding column in colModel
    ajaxSelectOptions: {
        data: { // "data" here is jQuery.ajax parameter 
            data: function () { // "data" here is the name of you custom parameter
                var row_id = $myGrid.getGridParam('selrow');
                return JSON.stringify({
                    "cu.STID": $myGrid.jqGrid('getCell', row_id, 'cu.STID'),
                    "wv.SVID": $myGrid.jqGrid('getCell', row_id, 'wv.SVID')
                });
            }
        }
    }
});

这篇关于jqgrid dataUrl函数代码段有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)