0
votes

It seems like wrong onClickSubmit is being fired. On loading the grid if i click on edit button and submit the onclicksubmit of the edit fires which is correct. but when i click on add the onclicksubmit of the edit fires!

If i reload the page and click on Add the onClickSubmit of the add fires which is correct, next i try to edit the onclickSubmit of the Add fires.. Please help!!

here is the code for

    jQuery("#treegrid").jqGrid('navGrid', '#ptreegrid', {
        view:true, refresh:true, search:false},//options 
        {width:700, height:300, checkOnSubmit:true, reloadAfterSubmit:true, 
            ajaxEditOptions: { contentType: 'application/json; charset=utf-8' },
            closeAfterEdit:true, closeOnEscape:true, bottominfo:"Fields marked with (*) are required",
            afterShowForm: function(eparams) {
                jQuery("#treegrid").setGridParam({datatype:'json'});
            },
            onclickSubmit: function(rp_ge, postdata)    {
                var rowid = jQuery("#treegrid").getGridParam('selrow');
                var rowdata = jQuery("#treegrid").getRowData(rowid);
                rp_ge.url = '../v1/OutlineItem?'+'&text='+$.URLEncode($("#text").val())+'&oper=edit'+
                        '&id='+rowid;
            }
        }, // edit options end
        {width:700, height:300, checkOnSubmit:true, reloadAfterSubmit:true, 
            closeAfterAdd:true, processData:"Processing", 
            ajaxAddOptions: { contentType: 'application/json; charset=utf-8' },
            closeOnEscape:true, bottominfo:"Fields marked with (*) are required",
            afterShowForm: function(eparams) {
                jQuery("#treegrid").setGridParam({datatype:'json'});
            },
            onclickSubmit: function(rp_ge, postdata)    {
                var rowid = jQuery("#treegrid").getGridParam('selrow');
                var rowdata = jQuery("#treegrid").getRowData(rowid);
                                    rp_ge.url = '../v1/OutlineItem?'+'&text='+$.URLEncode($("#text").val())+'&oper=add'+
                        '&id='+rowid;

            }
        }, // add options end
        {reloadAfterSubmit:true,closeOnEscape:true, mtype:"DELETE",
            ajaxDeleteOptions: { contentType: 'application/json; charset=utf-8' },
            serializeDelData: function (postdata) {
                  return ""; // the body MUST be empty in DELETE HTTP requests
             },
            onclickSubmit: function(rp_ge, postdata)    {
                var rowid = jQuery("#treegrid").getGridParam('selrow');
                var rowdata = jQuery("#treegrid").getRowData(rowid);
                rp_ge.url = '../v1/OutlineItem?'+'id='+rowid;
            }
        }, // del options 
        {closeOnEscape:true} // search options 
    );
    jQuery("#treegrid").jqGrid('navButtonAdd',"#ptreegrid",
            {caption:"",title:"Move Up", buttonicon :'ui-icon-arrowthick-1-n', 
            onClickButton:function(){ 
                var rowid = jQuery("#treegrid").getGridParam('selrow');
                jQuery("#selOutlineItemIdField").val(rowid);
                var temp = jQuery("#selOutlineItemIdField").val();

                $.ajax({
                     type: 'POST',
                     contentType: 'application/json; charset=utf-8',
                     accepts: 'application/json; charset=utf-8',
                     url: '../v1/OutlineItem?oper=up&id='+rowid,
                     data: 'oper=up&id='+rowid,      

// dataType: 'json', async: false, cache: false, error: function(){ }, success: function(data) { jQuery("#treegrid").trigger("reloadGrid"); jQuery("#treegrid").jqGrid('setSelection',temp); } });
} });

1

1 Answers

1
votes

I was able to get around with using recreateForm:true on edit as well as add, not sure why i would need to do that. Any thoughts??