Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a jqgrid in the page and need some help


after inline editing a value in the grid
i do

//this line gets the column name for use in next line
var name = myGrid.find('.ui-autocomplete-input').attr('name');
//getacid() is a function which is returning the right id
myGrid.jqGrid('setCell', lastselProductBrandMaps, name, getacid());
myGrid.jqGrid('saveRow', lastselProductBrandMaps , false);

but when it is posted to the controller the id field which i have just updated using setCell is missing.

i can confirm that using firefox before saveRow is called the row has all the right data in it in the same format as other rows.

i have added the autocomplete already to the form edit and it works perfectly because i have caught postdata on a event and put the right values in there and it works properly and sends right data back.

i want to know why it isnt working or if there any events on which i can catch the data using inline edit and modify.
Posted

1 solution

after doing some more googling didnt find one answer which worked which is to

http://stackoverflow.com/questions/12257555/jqgrid-aftersavefunc-not-called-on-saverow[^]

which is to also pass extra id item as part of extradata in saveRow function.

this however was no good for me as i would need to change my backend code and write some more functions and make many modifications to code each time i wanted to another autocomplete field.


so after some messing about with jquery in firefox ive found a better fix which i would like to share if anyone else needs.

what i did is


C#
//finds the autocomplete input inside my grid and take its name
var name = myGridBrands.find('.ui-autocomplete-input').attr('name');

//then instead of this line which was messing it up to update element
//myGridBrands.jqGrid('setCell', lastselBrands, name, getacid());

//i do this to update instead 
updateacinput( lastselBrands , name);

//then finally save row again which now works
myGridBrands.jqGrid('saveRow', lastselBrands , false);



the way jqgrid inline edit works is each row makes inputs with ids in the format of
"id ='#7_Name' " or " id ='#2_Size'"
so i send in the right id and name and use jquery .val() to update value and everything now works posting the right data to controller.

nice thing about this now is that i can use all over the place with pretty much 1-2 lines setup

C#
function updateacinput(id, name) {
    $('#' + id + '_' + name).val(getacid());
}


C#
function getacid() {
    return $('input:hidden[id=\'acid\']').val();
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900