0

Ok I came back to this, I just removed the formatter: "select", which was requiring a matched state key to display in the grid.


Ok I give up, my solution is:

search: false, editable: false

until the new version of JQGrid.


Ok, so looking at Oleg's code, it seems the solution there is to initially populate the state select with every possible value for all countries. Given that there are quite a few "states" (worldwide) that I deal with, it's a bit kludgy to pull down 3-4000 states just to find a match to the actual cell value. Still working on this.


I have dependent country and state dropdowns (both toolbar search, inline edit, and form edit). I am having a problem getting the row id in the datainit function, so that I can retrieve the country value from the datainit function of the state searchoptions/editoptions.

Surely there's a way to retrieve this? I tried setting a timeout as well, no luck:

    { name: "State", index: "MYSTATE", width: 50, align: "left", editable: true, formatter: "select", stype: "select", edittype: "select", sortable: true, editrules: { required: true, custom: true, custom_func: validateState },
            searchoptions:
            {
                value: GetStates('NG', true), // just hardcoded here for now
                dataInit: function (elem)
                {
                    var rowId = $(elem.target).closest('tr.jqgrow').attr('id');
                    var country = grid.jqGrid('getCell', rowId, 'Country');

...

Thanks.

Rich T.
  • 110
  • 3
  • 13

1 Answers1

0

Your current code can't work because the callback dataInit will be called before the new <select> or <input> element are placed on the page. Moreover elem.target is wrong. Even $(elem).closest('tr.jqgrow') will be always empty jQuery element. To be exact the code will be do possible if you would use the newest code of jqGrid from github. The reason is the resent changes which are made base on my suggestion. If you use the last released version of jqGrid 4.4.1 the changes are still not here. I think that one should make some additional changes in the code of jqGrid to make implementation of dependent selects more easy.

I find the implementation of dependent selects very complex and tricky. I would recommend you to examine the demo from the answer.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks for your response Oleg. I do have the dependent dropdowns working, using your code as a reference. The only problem is the initial condition, where I need the value of the country dropdown to populate the state dropdown. I tried the version from github and I'm not clear on what I need to do. I did notice that it broke the implementation of the filament group daterangepicker that I was using on the search toolbar. – Rich T. Nov 30 '12 at 15:16