JqGrid + Autocomplete

后端 未结 1 511
名媛妹妹
名媛妹妹 2020-12-20 10:34

I\'m having trouble implementing autocomplete in jqgrid. I\'ve walked researching, alias until I based this question on a site that currently do not meet. The problem is thi

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

    First of all you don't need to use edittype : 'custom' to be able to use jQuery UI Autocomplete. Instead of that you can use just dataInit.

    You can define myAutocomplete function for example like

    function myAutocomplete(elem, url) {
        setTimeout(function () {
            $(elem).autocomplete({
                source: url,
                minLength: 2,
                select: function (event, ui) {
                    $(elem).val(ui.item.value);
                    $(elem).trigger('change');
                }
            });
        }, 50);
    }
    

    and then use

    { name:'COD_OBJ_EST', hidden: true, editable: true,
        editoptions: {
            dataInit: function (elem) {
                myAutocomplete(elem, "autocomplete.php?id=estrategico");
            }
        }}
    

    Be careful that the name of parameter which will be send to the server is the standard name term instead of the name q which you currently use. I personally don't see any need to change the default name of the parameter.

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