jqGrid setSelect function with parametrized query

前端 未结 1 1833
心在旅途
心在旅途 2020-12-10 17:42

I\'m using jqGrid, on edit/add function I want to have a drop down list in one of these fields.

This works if i use the setSelect function as this:

$         


        
相关标签:
1条回答
  • 2020-12-10 18:10

    If I correct understand your question you use editoptions with dataUrl. You want to have the URL which has additional parameter tempid which value should be the rowid of the current selected row.

    From the syntax of your question I suppose that you use some commercial jqGrid for PHP product from trirand.net. In the case you should use tag [jqgrid-php]. jqGrid is pure JavaScript open source product. So I answer how you can add dataUrl parameter in JavaScript.

    jqGrid has ajaxSelectOptions option which can be used to modify the jQuery.ajax options of the call which use dataUrl. You can do following

    var myGrid = $("#list");
    
    myGrid.jqGrid({
        // all your current parameters of jqGrid and then the following
        ajaxSelectOptions: {
            data: {
                tempid: function () {
                    return myGrid.jqGrid('getGridParam', 'selrow');
                }
            }
        }
    });
    

    If the data parameter of jQuery.ajax contain a method instead of a property the method will be called every time of the corresponding jQuery.ajax call. I used the same trick in the answer.

    0 讨论(0)
提交回复
热议问题