0

I followed the specifications founded in jqgrid documentation but an error is occurring when I try to save the row. here the example code:

<script>
function myelem (value, options) {
  var el = document.createElement("input");
  el.type="text";
  el.value = value;
  return el;
}

function myvalue(elem, operation, value) {
    if(type=='get') {
       return $(elem).find("input").val();
    } else if(type == 'set') {
       $('input',elem).val(stringvalue);
    }
}
jQuery("#grid_id").jqGrid({
...
   colModel: [ 
      ... 
      {name:'price', ..., editable:true, edittype:'custom',
       editoptions:{custom_element: myelem, custom_value:myvalue} },
      ...
   ]
...
});
</script>

in the following line in debug I found that type is undefined is there any other method to know in that point if it is a set or a get of the value.

...
if(type=='get') {
...
Oleg
  • 220,925
  • 34
  • 403
  • 798
eKelvin
  • 921
  • 1
  • 9
  • 25

1 Answers1

2

You should use of course operation instead of type and the value instead of stringvalue. It seems a bug in the jqGrid documentation. You should additionally place the code of jQuery("#grid_id").jqGrid({...}); inside of jQuery(document).ready(function() {/*place your code here*/}); handler.

I recommend you also to read this answer and use recreateForm:true if you use form editing.

UPDATED: Because the documentation of jqGrid is wiki documentation and everybody can modify it I modified just now the corresponding place in the documentation which you probably used.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I saw the value of the operation operand but it contains the name of the cell and not the type of the operation – eKelvin Apr 10 '11 at 07:03
  • @ZeroAbsolute: I am trying to help you, but you posted too few information. For example, it is not clear which editing mode you use (form editing, inline editing or cell editing). Every editing mode has his own code. For example [here](https://github.com/tonytomov/jqGrid/blob/v4.0.0/js/grid.formedit.js#L341) and [here](https://github.com/tonytomov/jqGrid/blob/v4.0.0/js/grid.formedit.js#L575) you can see 'get' and 'set' for the form editing. The second parameter is here correct. You should post more your code which you use. – Oleg Apr 10 '11 at 10:09
  • @ZeroAbsolute: In cases of inline editing or cell editing you need only implement simplified form of `custom_value` where the second parameter is always 'get'. Probably [one working example](http://www.ok-soft-gmbh.com/jqGrid/Ranking.htm) which I prepared for [the answer](http://stackoverflow.com/questions/4842262/jqgrid-implementing-of-custom-cell-integration-of-raty-plugin/4842450#4842450) will help you more. – Oleg Apr 10 '11 at 10:21
  • Yes I use inline editing and yes I implemented like you, and seems to be function well. – eKelvin Apr 11 '11 at 09:23