jqGrid的editoptions dataurl不使用AJAX得到什么呢? [英] JQGrid editoptions dataurl not using ajax get?

查看:1315
本文介绍了jqGrid的editoptions dataurl不使用AJAX得到什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 editoptions一个数据网格:{dataUrl:?的getMetaData类型='+ +的myType'和;列= colOne'} 。我也有为了做一个自定义的报头校验提出请求后绑定功能的 ajaxComplete 事件。这是工作的罚款上的一切,我已经看到,除了dataUrl要求JQGrids请求。阿贾克斯完全不火进行GET请求后。 ajaxStart <$ C C $>和 ajaxStop 确实被解雇适当。完成/错误/成功都没有。

I have a data grid using editoptions:{dataUrl:'getMetadata?type=' + myType+ '&column=colOne'}. I also have bound a function to the ajaxComplete event in order to do a custom header check after requests are made. This is working fine on everything I've seen with JQGrids request except the dataUrl request. Ajax complete does not fire after the get request is performed. ajaxStart and ajaxStop are indeed getting fired appropriately. Complete/Error/Success are not.

据该jqGrid的文档dataUrl应该使用Ajax调用,以获取数据。

According to the jqgrid documentation for dataUrl it should be using an ajax call in order to grab the data.

通过Ajax调用时所获得的数据,并应与所需的选项有效的HTML select元素......

'The data is obtained via an AJAX call and should be a valid HTML select element with the desired options ...'

有没有别的东西,我在这里丢失?下面结合code。

Is there something else I'm missing here? Binding code below.

$('body').bind('ajaxComplete',function(event,request,settings){
    if (request.getResponseHeader('REQUIRES_AUTH') === '1'){
       location.reload();
    };
});
//Other binds added to see what is getting fired
$('body').bind('ajaxError',function(event,request,settings){
    if (request.getResponseHeader('REQUIRES_AUTH') === '1'){
       location.reload();
    };
});
$('body').bind('ajaxSuccess',function(event,request,settings){
    if (request.getResponseHeader('REQUIRES_AUTH') === '1'){
       location.reload();
    };
});
$('body').bind('ajaxStart',function(){
    var b = "ABC";
    var c = "DEF";
});
$('body').bind('ajaxStop',function(event,request,settings){
    var b = "ABC";
    var c = "DEF";
});

编辑:忘了补充该请求是回来了200状态

Forgot to add that the request is coming back with a 200 status.

-----------------------------这里阿贾克斯选择选项的问题------------- -----------

-----------------------------Ajax Select Options issue here------------------------

把任何地方的时候(目前的document.ready)导致所有选择框,以在搜索中不会显示。下面code

The following code when put anywhere (currently in document.ready) is causing all select boxes to not display in searches.

$.extend($.jgrid.defaults, {
            ajaxSelectOptions: {    
                complete: function (jqXHR) {
                    if (jqXHR.getResponseHeader('REQUIRES_AUTH') === '1') 
                    {
                        location.reload();
                    } 
                    return;
                }
        }});

Col​​Model和名称

ColModel and Names

    gridForm.colNames = ['ID','Field1','Field2','Field3','Field4','Field5','Last User Id','Modified Date' ];
gridForm.colModel = [
                      {name:'id', editable: false, edittype:'text',search:true, stype:'text'},        
                      {name:'Field1', editable: checkedOutByUser, edittype:'text', search:true,editrules:{required:true}, stype:'text'},
                      {name:'Field2', editable: checkedOutByUser, edittype:'select', editoptions:{dataUrl:dataUrl + "&search=false"}, search:true,editrules:{required:true}, searchoptions:{dataUrl:dataUrl + "&search=true"}, stype:'select'},
                      {name:'Field3',  editable: checkedOutByUser, edittype:'select', editoptions:{dataUrl:dataUrl + "&search=false"}, editrules:{required:true},search:true, searchoptions:{dataUrl:dataUrl + "&search=true"}, stype:'select'},
                      {name:'Field4',  editable: checkedOutByUser, edittype:'select', editoptions:{dataUrl:dataUrl + "&search=false"}, editrules:{required:true}, search:true, searchoptions:{dataUrl:dataUrl + "&search=true"}, stype:'select'},
                      {name:'Field5', editable: false, edittype:'text', search:true, stype:'text'},
                      {name:'userId', editable: false, edittype:'text', search:true, stype:'text'},
                      {name:'modifiedDate', editable: false, search:true, stype:'text', searchoptions:{dataInit:function(el){defaultCalendar.create(el, "componentGrid");}}}                             
                      ];

电网的定义,使用一些基于三元,所以我们可以重新使用jqGrid的要求类似网格

Grid definition, using some ternary based so we can re-use the jqgrid call for similar grids

    $("#myGrid").jqGrid(
        {
            caption:gridForm.caption,
            overflow:'hidden',
            url:gridForm.url?gridForm.url:url,
            height: gridForm.height?gridForm.height:'auto',
            datatype: "json",
            colNames:gridForm.colNames,
            colModel:gridForm.colModel,
            recordtext: 'Record(s) {0} - {1} of {2}', 
            rowNum: 20, 
            sortname: gridForm.sortindex?gridForm.sortindex:"id",
            sortorder: gridForm.sortorder?gridForm.sortorder:"desc",
            cellEdit: false,
            cellurl : 'updateRow', 
            editurl:'addRow',
            cellsubmit : 'remote',
            toolbarfilter: true,
            onCellSelect:gridForm.onCellSelect?gridForm.onCellSelect:null,
            pager: jQuery('#pager'),
            viewrecords: gridForm.viewrecords?gridForm.viewrecords:true,
            gridview: gridForm.gridview?gridForm.gridview:true,
            shrinkToFit: true,
            multiselect: gridForm.multiselect?gridForm.multiselect:true});
jQuery("#myGrid").jqGrid('filterToolbar');

最后,正在从数据URL返回的HTML

and finally, the HTML being returned from the data URL

<select><option value=''</option><option value='Dummy Entry'>Dummy Entry</option><option value='Next Entry'>Next Entry</option><option value='ThirdEntry'>ThirdEntry</option><option value='FourthEntry'>FourthEntry</option></select>

对不起文本墙,但我想补充的一切,可能会显得非常有用。请注意,这完全正常工作(请在搜索填充框)在众多(10+)jqgrids,我们有,直到使ajaxSelectOptions默认。

Sorry about the wall of text, but I tried to add everything that might seems useful. Note that this has worked perfectly fine (select boxes in search populating) across numerous (10+) jqgrids that we have until enabling the ajaxSelectOptions default.

推荐答案

我会建议你使用的 jqGrid的的ajaxSelectOptions 选项自定义Ajax请求,它使用jqGrid的获取从 dataUrl 。我希望参数 ajaxSelectOptions 可以看看你的情况,比如

I would recommend you to use ajaxSelectOptions option of jqGrid to customize the Ajax request which uses jqGrid to get data from dataUrl. I hope that the parameter ajaxSelectOptions could look in your case like

ajaxSelectOptions: {
    complete: function (jqXHR) {
        if (jqXHR.getResponseHeader('REQUIRES_AUTH') === '1') {
            location.reload();
        }
    }
}

这篇关于jqGrid的editoptions dataurl不使用AJAX得到什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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