0

編集が必要なJqgridがあります。編集後にデータを保存するようにグリッドを構成することに成功しましたが、問題は、データが保存されたときに、データベースに存在するデータでグリッドが更新されないことです。たとえば、バージョンフィールドはアプリケーションバックエンドによって自動的に更新されますが、編集が行われた後は更新されず、古い値が表示されます。afterSubmitafterCompleteを試しました

うまくいきませんでした。また、関数が呼び出されたことを確認するためにアラートを配置しましたが、アラートも表示されませんでした。さらに、loadonceをfalseに設定し、reloadaftersubmitをtrueに設定しましたが、これも機能しませんでした。問題は、編集を正しく構成していないか、上記のパラメーターを間違った場所に配置したことである可能性があると思います。

保存(編集)が完了すると、更新されたデータ(全体のページ)がJqgridに(jsonとして)返されます。ここでの問題は、古いデータが表示され、編集後にこの更新されたデータを表示するにはどうすればよいかということです。

更新:ポップアップボックスを介して編集すると、afterSubmitが実行されることがわかりました。ただし、編集は、テーブル自体のデータを編集できるformatoptionsを介して行われます。これで、ポップアップを使用せずにデータを編集してグリッド自体から保存したときに、afterSubmitを起動してテーブルを更新する必要があります。afterSubmitはどこに配置しますか/これを実現するにはどうすればよいですか。

/**
 * Initialize and Draw JQGrid
 * @return
 */
function drawFOMJQGrid(){

    var lastsel2;

    jQuery("#tblGrid").jqGrid({     

        height: 180, 
        width:990,
        datatype: "json", 
        colNames:['','Hotel','Outlet','Major Group','Item Group','Version'], 
        jsonReader : {
              root: "regDetails", 
              page: "page",
              total: "total",
              records: "records",   
              repeatitems: false
        },
        colModel:[ 
            {name: 'myac', width:80, fixed:true, sortable:false, resize:false, formatter:'actions', formatoptions:{keys:true}},
            {name:'hotelName',index:'hotelName',align:"left",width:30,resizable:false}, 
            {name:'majorGroupName',index:'majorGroupName',align:"left", width:20,resizable:false}, 
            {name:'itemGroupName',index:'itemGroupName', width:30,align:"left",resizable:false},
            {name:'version',index:'version', width:20,align:"right",resizable:false,editable:true,hidden: false}


        ],

        onSelectRow: function(id){
        },
        /*afterSubmit : function(response, postdata){
                        alert("AAAA");
        },  
        afterComplete : function(response, postdata){
                        alert("AAAA2");
        },  */              
        //rowList:[10,20,30], 
        rowNum:5,   
        pager: '#divGridPg', 
        sortname: 'hotelName', 
        viewrecords: true, 
        sortorder: "outletName",
        gridview: true, 
        bgiframe: true,
        autoOpen: false,
        caption: 'POS Item Pricing',
        forceFit: false,
        loadtext: 'Loading ...',
        sortable: true,
        loadonce: false,
        editurl:  "itemPricingSave.action", //"/js/itemPricing/server.js",          
        datatype: "json"




    }); 



    $("#tblGrid")[0].addJSONData(regGridJSONData);
    $("#tblGrid").setGridParam({datatype: 'json'});
    jQuery("#tblGrid").jqGrid('navGrid','#divGridPg',{edit:true,add:false,del:false,reloadAfterSubmit:true});       


}

/**
 * Initialize and Draw JQGrid
 * @return
 */
function drawFOMJQGrid(){

    var lastsel2;

    jQuery("#tblGrid").jqGrid({     

        height: 180, 
        width:990,
        datatype: "json", 
        colNames:['','Hotel','Outlet','Major Group','Item Group','Version'], 
        jsonReader : {
              root: "regDetails", 
              page: "page",
              total: "total",
              records: "records",   
              repeatitems: false
        },
        colModel:[ 
            {name: 'myac', width:80, fixed:true, sortable:false, resize:false, formatter:'actions', formatoptions:{keys:true}},
            {name:'hotelName',index:'hotelName',align:"left",width:30,resizable:false}, 
            {name:'majorGroupName',index:'majorGroupName',align:"left", width:20,resizable:false}, 
            {name:'itemGroupName',index:'itemGroupName', width:30,align:"left",resizable:false},
            {name:'version',index:'version', width:20,align:"right",resizable:false,editable:true,hidden: false}


        ],

        onSelectRow: function(id){
        },
        /*afterSubmit : function(response, postdata){
                        alert("AAAA");
        },  
        afterComplete : function(response, postdata){
                        alert("AAAA2");
        },  */              
        //rowList:[10,20,30], 
        rowNum:5,   
        pager: '#divGridPg', 
        sortname: 'hotelName', 
        viewrecords: true, 
        sortorder: "outletName",
        gridview: true, 
        bgiframe: true,
        autoOpen: false,
        caption: 'POS Item Pricing',
        forceFit: false,
        loadtext: 'Loading ...',
        sortable: true,
        loadonce: false,
        editurl:  "itemPricingSave.action", //"/js/itemPricing/server.js",          
        datatype: "json"




    }); 



    $("#tblGrid")[0].addJSONData(regGridJSONData);
    $("#tblGrid").setGridParam({datatype: 'json'});
    jQuery("#tblGrid").jqGrid('navGrid','#divGridPg',{edit:true,add:false,del:false,reloadAfterSubmit:true});       


}
4

2 に答える 2

0

グリッドのリロードを強制するために次のことを行いました。

.navGrid('#pager',
                    {edit:true,
                    add: true, 
                    del:true,refresh:false},
              { // edit options

                    afterSubmit: function() {
                        comptes[0].clearToolbar();
                        comptes.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
                          return [true,'',false]; // no error and no new rowid
                         }
                }, 
                { // add options

                     afterSubmit: function() {
                            comptes[0].clearToolbar();
                            comptes.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
                        return [true,'']; // no error
                    }
                } ,
                { // delete options
                     afterSubmit: function() {
                            comptes[0].clearToolbar();
                            comptes.jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
                        return [true,'']; // no error
                    }
                }       
               );
于 2012-09-05T07:33:43.773 に答える
0

次のように、すべての編集プロセスの後に、新しいデータで jqGrid をリロードしてみてください。

jQuery("#grid").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');
于 2017-05-12T17:38:15.420 に答える