English 中文(简体)
jqGrid inline edit:如果员额回归错误[重复],如何再次储蓄
原标题:jqGrid inline edit: how to save again if post returns error [duplicate]

jQgrid row is edited using inline editing mode. Pressing Enter sends data to server using http POST . POST method returns status 400 Bad reguest if there was some error. errorofunc in code below show error in this case. User corrects data in row and presses enter again.

Pressing enter is ignored, nothing happens. It looks like Enter key is unbound if 404 error is returned. Changes in edited row are lost, they cannot saved.

我试图犯错误。

restoreAfterError = false; grid.restoreAfterErorr = false;

但是,在出现错误后,行刑仍不能再拯救。

How to allow to save correct row data after 400 error is returned ?

<script type="text/javascript">
var lastSelectedRow;
$(function () {
            var grid = $("#grid");
            grid.jqGrid({
                url:  /Grid/GetData ,
                datatype: "json",
                mtype:  POST ,
                scroll: 1,
                multiselect: true,
                multiboxonly: true,
                scrollingRows : true,
                autoencode: true,
                colModel: [
        { name:  Source , fixed: true, editable: true, width: 30 },
        { name:  Est , fixed: true, editable: true, width: 271 },
        { name:  Istopic , fixed: true, editable: true, width: 57 },
        {name:  Critical , fixed: true, editable: true, width: 50}
    ],

                gridview: true,
                pager:  #pager ,
                sortname:  est ,
                viewrecords: true,
                rowNum: 30,
                sortorder: "asc",
                editurl:  /Grid/Edit 
            });

            $("#grid").jqGrid( bindKeys , {
                onEnter: function(rowid) {
                    doeditRow(rowid);
                }
            }  );

        });

        function doeditRow(rowID) {
            var grid2 = $("#grid");
            if (rowID && rowID !== lastSelectedRow) {
                grid2.jqGrid( restoreRow , lastSelectedRow);
                lastSelectedRow = rowID;
            }
            invokeEditRow();
        }

        function errorfunc(rowID, response) {
            // todo: why this does not allow Enter key to continue ase after error:
            restoreAfterError = false;
            $("#grid").restoreAfterErorr = false;
            alert(response.responseText);
            lastSelectedRow = rowID;
            invokeEditRow();
            return true;
        }


        function invokeEditRow() {
             $("#grid").jqGrid( editRow , lastSelectedRow ,true,null, null, null, {},
                 null,
                 errorfunc
             );
        }
    </script>

<div id="grid1container" style="width: 100%;">
    <table id="grid">
    </table>
    <div id="pager">
    </div>
</div>

UPDATE: errrofunc calls editrow which according to https://github.com/tonytomov/jqGrid/blob/master/js/grid.inlinedit.js should set enter key again to save. For unknown reason this does not occur.

UPDATE: in errorfunc grid. is changed to

        $("#grid").restoreAfterErorr = false;

according to Oleg comment

最佳回答

You use variable grid inside of errorfunc implementation (grid.restoreAfterErorr). The grid is undefined and you have exception in the line.

<>UPDATED: ou should取而代之alert(response.responseText);

$.jgrid.info_dialog($.jgrid.errors.errcap, <div class="ui-state-error"> +
    response.responseText + </div> , $.jgrid.edit.bClose,{buttonalign: right });

如标准案件一样,见同一风格的方言箱。 在线编辑的<代码>rorfunc负责显示错误信息本身。

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签