English 中文(简体)
jqGrid - inline editing with autocomplete
原标题:

I am sure that I saw it already in an example but can t find it again :(

I have a jqGrid with inline editing. That works fine. One column has a select box with 200 entries. Those get retrieved from a database query already.

Since 200 entries are too much, I want to have an input field and a live search. Once clicked on it, the ID should be saved.

Does anyone know an example?

Many thanks, Antonia

问题回答

You can use jQuery-ui autocomplete, since you already have the jquery ui library included. Add combobox.js which will set up the autocompletion based on the values of the select box, simply a class "combobox" to it.

// jquery and jquery UI already loaded...
<script src="combobox.js"></script>
<select class="combobox">
    <option value="foo">foo</option>
    <option value="bar">bar</option>
    <option value="baz">baz</option>
</select>

Live example: http://jsfiddle.net/CJTd2/1/

try with this:

function element(value,options){
    return $( <input type="hidden" value=" +value+ " /> );
}
function elementval(elem){
    return elem.val();
}
function fieldfunctions(id){
    $( "#"+id+"_name").autocomplete({
        source: "list.php",
        minLength: 2,
        select: function(event, ui) {
            $("#"+id+"_id_name").val(ui.item.id);
        }
    });
}

$("#table").jqGrid({
    url:  data.php ,
    datatype: "json",
    mtype:  POST , 
    height: 400,
    colNames: [ Name , Id name ],
    colModel: [
        {name:  id_name ,width: 30,hidden:true,editable:true,edittype: custom ,editoptions:{custom_element:element,custom_value:elementval}},
        {name:  name ,index:  name ,editable:true,edittype: text ,width: 100}

    ],
    onSelectRow: function(id){
        $("#table").jqGrid( editRow ,id, true,fieldfunctions);
        }
    });




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签