1

I'm using JQgrid, with a select/dropdown in my project, and have implemented it in a fashion similar to this

I need to have an on select even or something that'll allow me to execute some other code, but not sure how to go about it?

Rohan Büchner
  • 5,333
  • 4
  • 62
  • 106

1 Answers1

1

You can use dataEvents property of the editoptions to bind any event like 'change' event to the select in the editing. In the answer you will find an example of such code.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank you! (also thanks for answering most of other jqgrid questions out there :P been a great help so far) jqGrid is very flexible/powerful indeed :D – Rohan Büchner Mar 05 '12 at 09:47
  • While I'm at it (i could create a question for this, but would you know hos to preselect a value in the dropdown during editing, when using the modal? (or a link a could read up on how to do it) – Rohan Büchner Mar 05 '12 at 09:50
  • @Yenros: You are welcome! I'm glad the my old answers was also helpful for you. The preselection can depend from the exact requirement and context. In some situations it's just enough to use `defaultValue` property of the `editoptions` option. In other situations it will be need to use `dataInit` or some other callback which will be specific for the editing mode which you use (form editing, row editing or cell editing). – Oleg Mar 05 '12 at 10:02
  • @Oleg: Is it possible to pass some parameters into dataInit-method? I am talking about such parameters $('#grid').getRowData(id)['colName']. – Anatoliy Aug 22 '12 at 08:14
  • @Anatoliy: You can define some your function which has parameters like `var myDataInit = function (elem, a, b) {...}` and call it inside of `dataInit` with different parameters. Like `dataInit: function (elem) { myDataInit(elem, "x", "y") }` and something like `dataInit: function (elem) { myDataInit(elem, "a", "b") }` for another column. – Oleg Aug 22 '12 at 08:49
  • @Oleg: Thanks for quick response. I have been trying to implement something like this: 'dataInit'=> "function (elem) {var rowid = jQuery('#grid').jqGrid('getGridParam', 'selrow');var box_no = $('#grid').getRowData(rowid)['box_no'];}". But it does not work. Both vars are null or undefined. – Anatoliy Aug 22 '12 at 09:20