JQgrid - accessing inlineNav return data

1.7k views Asked by At

Only yesterday I started using jq-grid and the way things are done is somewhat vague to me thus far. See below...

    function setUpStudentEntryGrid(numberofstuds){
        $("#studentset").jqGrid({
            url:"<c:url value='/registrationcarts/constructjson/'/>"+numberofstuds, 
            datatype: "json",
            colNames:['id','First Name', 'Last Name'], 
            colModel:[ 
                       {name:'id',index:'id', width:60}, 
                       {name:'firstName',index:'fName', width:300, editable:true},
                       {name:'lastName',index:'lastName', width:300, editable:true}
                     ],                  
            rowNum:10, 
            rowList:[10,20,30], 
            pager: '#pager',
            sortname: 'id', 
            viewrecords: true, 
            sortorder: "desc",
            editurl: "<c:url value='/students/addnew'/>", 
            caption: "Using navigator"
        });
        $('#studentset').jqGrid('navGrid',"#pager",{edit:false,add:false,save:false,del:false,search:false});
        $('#studentset').jqGrid('inlineNav',"#pager");
    }

I have inline editing working and data is going to the database. My action simply returns a string saying "student saved". On fire-bug I am geting my return string in the responce so my action is working .I plan to use $('#studentset').jqGrid('setRowData',Newly_created_ID,{firstName:"name", lastName:"name"}); after modifying my string.

How do I access and update the row ID manually using inlineNav as show above?

I am grsaping at straws, so to speak, as I am not too sure on how to set this up. Can someone please advise.

Thank you.

1

There are 1 answers

0
Faiyet On BEST ANSWER

Ok so all I needed to do was call data.tosource and I was able to see everything contained in the data object. The key I was interested in is the responseText, hence

            onSelectRow: function(id){ 
                if((id != null)&&(id!==lastsel)){ 
                    $('#studentset').jqGrid('restoreRow',lastsel); 
                    $('#studentset').jqGrid('editRow',id,true,'',function(data){
                        alert(data.responseText);

                    });                         
                    lastsel=id; 
                } 
            }

Hope this helps someone in need !