Monday, February 13, 2012

jqgrid - column/cell with jquery autocomplete

I implemented a column with autocomplete in afterEditCell event and it works well!

var grid = $('#mygrid');

if (cellname=='myColumnName') {
                $("#"+iRow+"_"+cellname,"#grid1).autocomplete({
                    source: cList, //a json data from ajax and stored in javascript array, you can see how I get it from my previous post.
                    select: function( event, ui ) {
                        $(this).val( ui.item.value ); 
                        grid.saveCell(rowid,iCol);
                        return false;
                    }               
                }).data("autocomplete")._renderItem = function( ul, item ) {
                        return $( "<li></li>" )
                            .data( "item.autocomplete", item )
                            .append( "<a>" + item.label + "</a>" )
                            .appendTo( ul );
                }
            }

No comments: