1

I'm trying to do stuff (fill another select) when the user selects something in a select-type editor. I'm using the 'change'-event. The problem is, it does not trigger when I select someting!

    $("#my_grid").setColProp("my_col", {
        dataEvents: [
            {
                type: 'change',
                fn: function (e) {
                    alert("Do stuff here once I get the event to work!");
                }
            }
        ]
    });

Is maybe the 'change'-event not the one to use?

Also tried this way, in the definition:

              { name: 'my_col', index: 'my_col', width: 80, edittype: 'select', editable: true, editoptions: { dataEvents: [{ type: 'change', fn: function (e) { alert("safd") } }]} },
kaze
  • 4,299
  • 12
  • 53
  • 74

1 Answers1

1

It's important to know when, in which context you do the changes. You can do this before the corresponding editing field is created. I don't understand why you need to use setColProp for setting the dataEvents dynamically. Probably you will find the solution of your original problem in the answer.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I actually dont need to do it before. I've changed it to the columns definition, and edited my question. Still no trigger. I've looked att your other answer, it's really great but so big that I'm not sure what parts I actually need. – kaze Mar 26 '12 at 08:58
  • @kaze: Probably it's some understanding problem. You can for example open [the demo](http://www.ok-soft-gmbh.com/jqGrid/EditWithDependendSelects1.htm) in IE, start Developer Tools with F12, click on "start debigging" on the "Script" tab, set breakpoint inside of `fn` of `'change'` event (on the line `changeStateSelect($(e.target).val(), e.target);`), double click on a row os the grid to start row editing and select another option in the select. You will stay in the debugging line. So you will see that 'change'-event do fired. – Oleg Mar 26 '12 at 09:20
  • Alright! I've solved the problem now. You got me thinking about the order of where I add stuff to the grid. I found out that I had other code that is run later, that overwrote the event. Thanks! – kaze Mar 26 '12 at 09:20
  • 1
    Please expand on your solution. I'm having the same problem trying to get some cascading drop downs working. I have an alert in the 'change' event in exactly the same way you do. I also have the onSelectRow and onblClickRow events defined. Why would they override my field specific event? When I put a breakpoint on the alert line it does not break, even though I select a different value. – Nick.Mc Nov 08 '12 at 11:28
  • @ElectricLlama: Sorry, but I don't full understand the problems which you have. What you mean under "expand on your solution"? I can forward you to [the answer](http://stackoverflow.com/a/4480184/315935) with the demo which work for Inline editing, Form editing and the searching. – Oleg Nov 08 '12 at 11:52
  • I meant expand on this: . "I found out that I had other code that is run later, that overwrote the event". Its OK I've created a question that you will probably shortly answer anyway! – Nick.Mc Nov 09 '12 at 03:49