jquery - jqGrid custom onCellSelect not firing beforeSaveCell -


i writing piece of code inside oncellselect, executes fine

oncellselect: function (rowid, icol, cellcontent) {         if (icol > 0) {             $("#gridmain_d").jqgrid("resetselection");             $("#gridmain_d").setselection(rowid, true);         }     } 

but problem because of code beforesavecell event not firing. know because remove code beforesavecell starts working. have tried using return statement nothing works.

update
commented code written above , added code

beforeselectrow: function (rowid, e) {         var $self = $(this), icol, cm,             $td = $(e.target).closest("tr.jqgrow>td"),             $tr = $td.closest("tr.jqgrow"),             p = $self.jqgrid("getgridparam");          if ($(e.target).is("input[type=checkbox]") && $td.length > 0) {             $self.jqgrid("setselection", $tr.attr("id"), true, e);         }         else {             $self.jqgrid('resetselection');             $self.jqgrid("setselection", $tr.attr("id"), true, e);         }         return true;     }, 

but still beforesavecell event not firing.

update 2
jsfiddle replicates issue. http://jsfiddle.net/eranjali08/czvvk/1175/

there many callbacks depends each other. difference of such dependencies in different versions of jqgrid. recommend use beforeselectrow instead of oncellselect because first callback called on click on cell of jqgrid. information need can second parameter (e in code below) of beforeselectrow:

beforeselectrow: function (rowid, e) {     var $self = $(this),         $td = $(e.target).closest("tr.jqgrow>td");         icol = $.jgrid.getcellindex($(e.target).closest($td[0]),         colmodel = $self.jqgrid("getgridparam", "colmodel"),         columnname = colmodel[i].name;     //...     // 1 can use here $td.html(), $td.text() access content of cell     // columnname name of column cell clicked     // icol - index of column cell clicked     return true; // or false suppress selection } 

you need don't forget beforeselectrow should return value inform jqgrid whether select clicked row or not. values false or "stop" returned beforeselectrow suppresses selection of clicked row. other values allows selection.

updated: analysed code 1 more time , hope i've found reason of problem. use resetselection evil in case of usage of cell editing. @ the last line of resetselection.

t.p.savedrow = []; 

it destroys array holding information editing cell. cell can't saved or restored more.

to solve problem have remove resetselection code. if need use resetselection should replace example loop call of setselection. corresponding code close code below:

beforeselectrow: function (rowid, e) {     var $self = $(this), icol, cm, i, idsofselectedrows,         $td = $(e.target).closest("tr.jqgrow>td"),         $tr = $td.closest("tr.jqgrow"),         p = $self.jqgrid("getgridparam");      if ($(e.target).is("input[type=checkbox]") && $td.length > 0) {         $self.jqgrid("setselection", $tr.attr("id"), true, e);     }     else {         //$self.jqgrid('resetselection');         idsofselectedrows = p.selarrrow.slice(0); // make copy of array         (i = 0; < idsofselectedrows.length; i++) {             $self.jqgrid("setselection", idsofselectedrows[i], false, e);         }         $self.jqgrid("setselection", rowid, false, e);     }     return false; }, 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -