jqgrid dataUrl函数代码段遇到问题 [英] having trouble with jqgrid dataUrl function code segment

查看:73
本文介绍了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;
},

有人知道发生了什么事吗?

Does anyone know whats going on?

更新:

{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不能是函数.如果在选择过程中需要将任何其他信息发送到服务器,则可以使用此处选项>.在您的情况下,将涉及以下内容:

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函数代码段遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆