ok, I will try to explain:
1. creation of empty grid
S1Q5Grid = $("#S1Q5").jqGrid({
url:"/wg25/survey/s1q5list/survey_id/0?nd="+new Date().getTime(),
editurl:"/wg25/survey/s1q5edit/survey_id/0?nd="+new Date().getTime(),
/*other stuff not relevant for explanation */
});
2. creation of navbar
$("#S1Q5").navGrid('#S1Q5_pager', {edit:true,add:true,del:true,search:false},
{width:480,height:140,reloadAfterSubmit:true,beforeSubmit:doIt1},
{width:480,height:140,reloadAfterSubmit:true,beforeSubmit:doIt1},
{reloadAfterSubmit:true});
3. I have a select to choose trimester and call corresponding survey via ajax with a callback
function ajxGetSurvey(obj) {
val = obj[obj.selectedIndex].value;
if(parseInt(val, 10) == 0) {
alert("Please choose a trimester.");
}
else {
$.getJSON("/wg25/survey/getsurvey/trimester_id/" + val, ajxGetSurveyResult);
}
}
4. in the callback, I set some other stuff not related to grid, then I want to refresh grid based on returned value (that’s why I need to change editurl to pass survey_id
function ajxGetSurveyResult(data) {
if(data.status == "OK") {
//some other stuff
//NOTE: here survey_id has a value different from 0
S1Q5Grid.setGridParam({url:"/wg25/survey/s1q5list/survey_id/" + survey_id + "?nd=" + new Date().getTime()})
S1Q5Grid.setGridParam({editurl:"/wg25/survey/s1q5list/survey_id/" + survey_id + "?nd=" + new Date().getTime()});
S1Q5Grid.trigger("reloadGrid");
}
}
5. to be sure my edit url is ok, I check it in my beforeSubmit doIt1 function
function doIt1(postData) {
alert(S1Q5Grid.getGridParam('editurl'));
//HERE THE VALUE IS OK
return true;
}
6. I open the form and submit
-the first time, the editurl is ok, it goes to the right place, for example:
http://localhost/wg25/survey/s1q5edit/survey_id/11?nd=1209928582515
-the buttons are OK, labelled ‘Submit’ and ‘Cancel’
7. I change the trimester (Ajax + callback)
8. Grid refresh with right values, url for retrieving data is OK
9. I open a form = PROBLEMS
-the labels are now all to ‘0’
-the doIt1 function alert me that editurl is changed (with survey_id=12 or whatever)
-the submission goes to former editurl (survey_id=11)
I can send all zipped code if you want.