English 中文(简体)
Jqgrid在提交书后使用,以获得新增加的记录。
原标题:Jqgrid use afterSubmit event to get the ID of newly added record

我正在使用以下法典添加新的记录。

jQuery("#list").jqGrid( editGridRow ,"new",{height:545, width:425,recreateForm:true,reloadAfterSubmit:false,addedrow: first ,closeAfterAdd:true,top:110,left:350,modal:true});

我正在使用再载荷After Submit:false, 即当新记录被加到电网时,我已经空出的电离层。

Can someone explain VERY simply how to get the ID of the new record and put it into the ID field in my grid.

I have found a previous answer here which seems to be what im looking for but I cant understand how to get it to work. The documentation says afterSubmit: function (response,postdata) {return [true, , new_id];} but I have no how to implement this.

Im new so I need it put very simply.

感谢任何帮助。

UPDATE: SERVER RESPONSE: response.responseText

( ! ) Notice: Undefined offset: 1 in D:wampwwwEstimateTrackerUpdateEstimates.php on line 32 Call Stack #TimeMemoryFunctionLocation 10.0036402872{main}( )..UpdateEstimates.php:0
( ! ) Notice: Undefined offset: 2 in D:wampwwwEstimateTrackerUpdateEstimates.php on line 32 Call Stack #TimeMemoryFunctionLocation 10.0036402872{main}( )..UpdateEstimates.php:0 String

附录2:

$(function () {
    $("#list").jqGrid({
        url: GetEstimates.php ,
        datatype:  xml ,
        mtype:  GET ,
        colNames:[ ID , Campaign Name , ClientsID , Client Name , Buyer Name , Client Ref , Description , Sales , Estimator ,  Date Received ,  Date Required , Status , Product Type , Date Submitted , Price (&pound) ,  Keren No. , Reason Lost , Won Price (&pound) , Notes ],
        colModel :[ {name: ID , key:true,index: ID , width:45,align: center ,editable:true,editoptions:{readonly:true,size:10, height:5}, {name: CampaignName , index: CampaignName , width:175, align: left ,editrules:{required:true},editable:true,editoptions:{size:35}}, {name: ClientsID , index: ClientsID , width:120, align: left ,editable:true,hidden:true}, {name: ClientName , index: ClientName , width:120, align: left ,editrules: required:true,custom_func:notEmpty,custom:true},editable:true,edittype: select , editoptions:{dataUrl: ClientDropDownGrid.php ,dataInit: function () {
        var thisval = $("#ClientsID").val();
        $.get( GetBuyersGrid.php?id= +thisval, function(data) {
            var res = $(data).html();
            $("select#BuyerName").html(res);
        }); // end get
    }//end func
    ,dataEvents:[{type: change ,fn: function(e) {
        var thisval = $(e.target).val();
        $.get( GetBuyersGrid.php?id= +thisval, function(data){
            var res = $(data).html();
            $("select#BuyerName").html(res);
        }); // end get
    }//end func
    } // end type
    ] // dataevents
    }}, 
    {name: BuyerName , index: BuyerName , width:100, align: left ,editable:true,edittype: select ,editoptions:{dataUrl: BuyerDropDownGrid.php }},
    {name: ClientEstimateRef , index: ClientEstimateRef , width:125, align: left , align: left ,editable:true,editoptions:{size:25}},
    {name: Description , index: Description , width:125, align: left , align: left ,editable:true,editoptions:{size:25}},
    {name: SalesName , index: SalesName , width:100, align: left ,editrules:{required:true,custom_func:notEmpty,custom:true},editable: true,edittype: select ,editoptions:{dataUrl: SalesDropDownGrid.php },formoptions:{elmsuffix:  <a id="AddSales" href="AddSales.php">Add Sales</a>  }},
    {name: EstimatorName , index: EstimatorName , width:100, align: left ,editrules:{required:true,custom_func:notEmpty,custom:true},editable: true,edittype: select ,editoptions:{dataUrl: EstimatorDropDownGrid.php } },
    {name: DateReceived , index: DateReceived , width:80, align: center ,editrules:{required:true,custom_func:isValidDateRec,custom:true},editable:true,editoptions: {size: 15, maxlength: 10,dataInit: function(element) {$(element).datepicker({dateFormat:  dd/mm/yy }) } }}, 
    {name: DateRequired , index: DateRequired , width:80, align: center ,editrules:{required:true},editable:true,editoptions: {size: 15, maxlength: 10,dataInit: function(element) {$(element).datepicker({dateFormat:  dd/mm/yy }) } }}, 
    {name: Status , index: Status , width:100, align: left ,editable: true,edittype: select ,editoptions:{dataUrl: StatusDropDownGrid.php , defaultValue: 4 } },
    {name: ProductType , index: ProductType , width:100, align: left ,editrules:{required:true,custom_func:notEmpty,custom:true},editable: true,edittype: select ,editoptions:{dataUrl: ProductTypeDropDownGrid.php } },
    {name: DateSubmitted , index: DateSubmitted , width:80, hidden:false, align: center ,editable:true,editoptions: {size: 15, maxlength: 10,dataInit: function(element) {$(element).datepicker({dateFormat:  dd/mm/yy }) } }},
    {name: Price , index: Price , width:60, align: right ,editrules:{required:true,custom_func:isCurrency,custom:true},editable:true, formatter:currencyFmatter, unformat:unformatCurrency,editoptions:{size:15,defaultValue: 0.00 }, formoptions:{elmsuffix:  GBP }},
    {name: KerenNo , index: KerenNo , width:80, align: left ,editable:true,editoptions:{size:20}},
    {name: ReasonLost , index: ReasonLost , width:120, align: left ,editable: true,edittype: select ,editoptions:{dataUrl: ReasonLostDropDownGrid.php } },
    {name: WonPrice , index: WonPrice , width:60, align: right ,editrules:{required:true,custom_func:isCurrency,custom:true},editable:true, formatter:currencyFmatter, unformat:unformatCurrency, editoptions:{size:15,defaultValue: 0.00 }, formoptions:{elmsuffix: GBP }},
    {name: Notes , index: Notes , width:125, align: left , align: left ,editable:true,edittype: textarea ,editoptions:{dataInit: function(elem){$(elem).width(200); $(elem).height(45);}}}
    //{name: total , index: total , width:80, align: right }, 
    //{name: note , index: note , width:150, sortable:false} 
    ],
        pager:  #pager ,
        rowNum:20,
        rowList:[10,20,30],
        sortname:  ID ,
        sortorder:  asc ,
        viewrecords: true,
        gridview: true,
        caption:  Estimates ,
        width:880,
        height:400,
        multiselect:true,
        editurl: UpdateEstimates.php ,
        shrinkToFit:false
    });
    //edit row
    $("#editButton").click(function(){
        var gr = jQuery("#list").jqGrid( getGridParam , selrow );    
        if( gr != null ) jQuery("#list").jqGrid( editGridRow ,gr,{height:545, width:425,recreateForm:true,reloadAfterSubmit:false,closeAfterEdit:true,top:110,left:350,viewPagerButtons:false,modal:true,beforeShowForm: function(form) { $( #tr_DateSubmitted , form).show();}});
        else alert("Please Select Row");
    });

    //add row
    $("#addButton").click(function(){
        //var gr = jQuery("#list").jqGrid( getGridParam , selrow );
        jQuery("#list").jqGrid( editGridRow ,"new",{height:545, width:425,recreateForm:true,reloadAfterSubmit:false,afterSubmit: function(response){return [true,  , 45765 ];},addedrow: first ,closeAfterAdd:true,top:110,left:350,modal:true});
    });

});
问题回答




相关问题
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.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.