1

我有一个增强网格,哪些字段是可编辑的。一些字段将手动更改,而其他字段将动态更改。问题是我不想在ApplyEdit上存储值,我想强制保存值但我找不到解决方案。这就是它现在的样子,实际上效果很好。

dojo.connect(grid, "onApplyEdit", grid, function(evt, rowIndx, fieldIndx){
            var selected_item = grid.getItem(evt);
            //Not sure if this is the most efficient way but it worked for me
            var row_id = grid.store.getValue(selected_item, "row_id");
            var from_item_no = grid.store.getValue(selected_item, "from_item_no");
            var from_inventory = grid.store.getValue(selected_item, "from_inventory");
            var comment = grid.store.getValue(selected_item, "comment");
            edit_quantity = grid.store.getValue(selected_item, "quantity");
            var to_item_no = grid.store.getValue(selected_item, "to_item_no");
            var to_inventory = grid.store.getValue(selected_item, "to_inventory");
            var foundation = grid.store.getValue(selected_item, "foundation");

                // Instantiate some write implementing store.
                var store = grid.store;
                // Set our load completed handler up...
                var onCompleteFetch = function(items, request){
                    // Define the save callbacks to use
                    var onSave = function(){
                        dojo.xhrPost({
                            url: url,
                            content: {
                                row_id: row_id,
                                from_item_no: from_item_no,
                                from_inventory: from_inventory,
                                comment: comment,
                                quantity: edit_quantity,
                                to_item_no: to_item_no,
                                to_inventory: to_inventory,
                                foundation: foundation
                            },
                            handleAs: "text",
                            load: function(data){
                                console.log("Returned value: " + data);
                                global_saved_check = false;
                            },
                            error: function(error){
                                alert(error);
                            }
                        });// end xhrPost
                    } // end onSave

                    var onSaveError = function(error){
                            alert("Error occurred: " + error);
                    }

                    // If the store has modified items (it should), call save with the handlers above.
                    if(store.isDirty()){
                            store.save({onComplete: onSave, onError: onSaveError});
                    }
                } // end onCompleteFetch
                // Define a fetch error handler, just in case.
                var onFetchError = function(error, request){
                        alert("Fetch failed.  " + error);
                }
                // Fetch some data...  All items with a foo attribute, any value.
                store.fetch({query: {foo:"*"}, onComplete: onCompleteFetch});

        });//end connect onApplyEdit
4

0 回答 0