0

我是 jqGrid 的新手。我正在尝试在 editoptions 中使用 dataUrl 来为每个行编辑刷新选择框选项值(在显示编辑表单之前)。

但是我没有看到刷新发生,我确实看到了在 jqGrid 中编辑一行时在 firebug 中发出的任何 http 请求。

我在名为的列中调用一个 php 文件,在"loadPoleManagers.php"php文件中我返回带有选项的选择 html 标记,即纯 html 标记。dataUrlPole_manager

如果我遗漏了什么,你能请任何人给我建议吗?

下面是我的 jqGrid 代码。

$('#groups_grid').jqGrid({
    caption: 'Groups',
    hidegrid:false,
    height:'100%',
    width:1024,
    imgpath: 'style/jquery.plugins/jqgrid/steel/images',
    loadui:'disable',
    forceFit:true,
    pager: jQuery('#pagerGroups'),
    viewrecords:true,
    url:'data/xml/grid/groups.php',
    datatype: "xml",
    mtype:'POST',
    ajaxSelectOptions: { cache: false },
    colNames:['ID','Name', 'Complete day compulsory', 'Pole manager',
        'Support Leader', 'Itrack group name'],
    colModel:[
        {name:'id_group',index:'id_group', width:40, align:"center"},
        {name:'name',index:'name', width:70, resizable:true, editable:true,
            editoptions: {size:'20', maxlength:'45'}},
        {name:'complete_day_compulsory',index:'complete_day_compulsory',
            width:110, align:"center", resizable:true, sortable:true,
            editable:true, edittype:'select', editoptions: {value:"0:No;1:Yes"}},
        {name:'pole_manager',index:'pole_manager->last_name', width:100,
            resizable:true, sortable:true, editable:true,
            edittype:'select',editoptions:{dataUrl:'loadPoleManagers.php'}},
        {name:'support_leader',index:'support_leader->last_name', width:100,
            resizable:true, sortable:true, editable:true, edittype:'select',
            editoptions: {value:support_leaders}},
        {name:'itrack_group_name',index:'itrack_group_name', width:100,
            resizable:true, editable:true, edittype:'text'}
    ],
    rowNum:15,
    rowList:[5, 10, 15, 25],
    imgpath: 'style/jquery.plugins/jqgrid/steel/images',
    sortname: 'id_group',
    multiselect: false,
    onSelectRow: rowSelectedHandler,
    ondblClickRow: function(id){
        if(id){
            jQuery('#groups_grid').restoreRow(lastEditedGroup);
            jQuery('#groups_grid').editRow(id,true);
            lastEditedGroup=id;
        }
    },
    loadComplete: function(){
        lastEditedGroup = null;
        lastSelectedGroup = null;
    },
    editurl: 'data/forms_handle/edit_group.php'
    }).navGrid("#pagerGroups",
        {refresh: true, edit: true, add: true, del: true, search: true, view: false},
        {height:220, width:690, closeAfterEdit:true, recreateForm:true},
        {height:220, width:690, closeAfterAdd:true,recreateForm:true},
        {height:140, width:380},
        {height:80, width:450, closeAfterSearch:true,closeOnEscape:true,
            multipleSearch:true}
    );

谢谢。

4

1 回答 1

0

我使用该beforeShowForm功能解决了这个问题。

以下是在选择并单击行进行编辑时刷新选择框选项列表的完整代码。

$("#groups_grid").jqGrid({
    caption: "Groups",
    hidegrid:false,
    height:'100%',
    width:1024,
    imgpath: 'style/jquery.plugins/jqgrid/steel/images',
    loadui:"disable",
    forceFit:true,
    pager: jQuery('#pagerGroups'),
    viewrecords:true,
    url:'data/xml/grid/groups.php',
    datatype: "xml",
    mtype:'POST',
    ajaxSelectOptions: { cache: false },
    colNames:['ID','Name', 'Complete day compulsory', 'Pole manager', 'Support Leader', 'Itrack group name'],
    colModel:[                                          
        {name:'id_group',index:'id_group', width:40, align:"center"},
        {name:'name',index:'name', width:70, resizable:true, editable:true, editoptions: {size:'20', maxlength:'45'}},
        {name:'complete_day_compulsory',index:'complete_day_compulsory', width:110, align:"center", resizable:true, sortable:true, editable:true, edittype:'select', editoptions: {value:"0:No;1:Yes"}},
        {name:'pole_manager',index:'pole_manager->last_name', width:100,  resizable:true, sortable:true, editable:true, edittype:'select',editoptions: {value:pole_managers}},
        {name:'support_leader',index:'support_leader->last_name', width:100,  resizable:true, sortable:true, editable:true, edittype:'select', editoptions: {value:support_leaders}},
        {name:'itrack_group_name',index:'itrack_group_name', width:100,  resizable:true, editable:true, edittype:'text'}
    ],
    rowNum:15,
    rowList:[5, 10, 15, 25],
    imgpath: 'style/jquery.plugins/jqgrid/steel/images',
    sortname: 'id_group',
    multiselect: false,
    onSelectRow: rowSelectedHandler,
    ondblClickRow: function(id){ 
        if(id){
            jQuery('#groups_grid').restoreRow(lastEditedGroup);
            jQuery('#groups_grid').editRow(id, true);
            lastEditedGroup = id;
        }
    },
    loadComplete: function(){
        lastEditedGroup = null;
        lastSelectedGroup = null;
    },


    editurl: 'data/forms_handle/edit_group.php'
}).navGrid("#pagerGroups", 
    {
        refresh: true, edit: true, add: true, del: true, search: true, view: false},
    {
        height:220, 
        width:690, 
        closeAfterEdit:true, 
        recreateForm:true,
        beforeShowForm:function(formID) {
            $.post("data/xml/loadPoleManagers.php?group="+lastSelectedGroup, {},
                function(response){
                    //alert(response);
                    jQuery('#pole_manager',formID).empty().append(response);
                },
                 "text"
            );
        }
    },
    {height:220, width:690, closeAfterAdd:true,recreateForm:true},
    {height:140, width:380},
    {height:80, width:450, closeAfterSearch:true,closeOnEscape:true, multipleSearch:true}
);

在我的 data/xml/loadPoleManagers.php 文件中,我只返回 html 选项标签

"<"option>one"</"option">"
"<"option">"Two"</"option">"
于 2012-05-31T11:36:12.060 回答