Note that there are some explanatory texts on larger screens.

plurals
  1. POjqGrid autocomplete, select value and copy a value to another cell
    text
    copied!<p>I'm working on a project with Visual Studio 2010 Asp.Net MVC4 and jqGrid. when deploying the autocomplete and the user selects a value I need to copy a value to another cell as I can do to solve this problem? I attached a image and code. <img src="https://i.stack.imgur.com/ZpZAn.png" alt="enter image description here"></p> <p>this is my code, the autocomplete works, How I can copy a value to another cell from autocomplete?</p> <pre><code>jQuery(document).ready(function () { var lastSelection; jQuery("#tbFacturaCompra").jqGrid({ url: '@Url.Action("DatosFacturaCompra", "raFacturaCompra", new { area = "Operacion" })', editurl: '@Url.Action("DatosFacturaCompraABM", "raFacturaCompra", new { area = "Operacion" })', datatype: 'json', mtype: 'POST', postData: { IdOrden: IdOrden, ParTipoOrden: ParTipoOrden }, colNames: ['Del', 'Nit', 'Factura', 'Autorizacion', '', 'Cod. Control', 'Fecha', 'Importe', 'Estado', '', ''], colModel: [ { name: 'ac', width: 15, formatter: 'actions', formatoptions: { keys: true, editformbutton: false, delbutton: true, editbutton: false} }, { name: 'ofc_nit', index: 'ofc_nit', align: 'right', width: '50', editable: true, edittype: 'text', editoptions: { value : '', dataInit: function (elem) { value: ListarProveedores(elem); } } }, { name: 'ofc_nrofac', index: 'ofc_nrofac', align: 'right', width: '50', editable: true, edittype: 'text', editoptions: { style: "text-transform: uppercase"} }, { name: 'ofc_autorizacion', index: 'ofc_autorizacion', align: 'right', width: '50', editable: true, edittype: 'text', editoptions: { style: "text-transform: uppercase"} }, { name: 'ofc_alfanumerico', index: 'ofc_alfanumerico', editable: false, edittype: 'text', hidden: true }, { name: 'ofc_codigocontrol', index: 'ofc_codigocontrol', align: 'right', width: '50', editable: true, edittype: 'text', editoptions: { style: "text-transform: uppercase"} }, { name: 'ofc_fechafactura', index: 'ofc_fechafactura', align: 'center', width: '30', editable: true, formatter: 'date', formatoptions: { srcformat: "d-m-Y", newformat: "d/m/Y"} }, { name: 'ofc_importe', index: 'ofc_importe', align: 'right', width: '25', editable: true, formatter: 'number', formatoptions: { decimalPlaces: 2} }, { name: 'ofc_parestadofaccom', index: 'ofc_parestadofaccom', width: '20', editable: true, edittype: "select", editoptions: { value: "V:V;F:F"} }, { name: 'ofc_partipoorden', index: 'ofc_partipoorden', editable: true, edittype: 'text', hidden: true }, { name: 'ofc_idordenpago', index: 'ofc_idordenpago', editable: true, edittype: 'text', hidden: true } ], pager: '#pg_tbFacturaCompra', rowNum: 15, rowList: [15, 30, 45], sortname: 'ofc_fechafactura', sortorder: 'desc', viewrecords: true, rownumbers: true, imgpath: '/content/themes/base/images', multiselect: false, height: 170, width: 700, footerrow: true, grid: true, toolbar: [true, "top"], loadComplete: function (data) { var id = $.jgrid.randId(); var $grid = $('#tbFacturaCompra'); var mydata = [{ ofc_nit: "", ofc_nrofac: "", ofc_autorizacion: "", ofc_alfanumerico: "-.-", ofc_codigocontrol: "", ofc_fechafactura: FechaServ, ofc_importe: "0.0", ofc_parestadofaccom: "V", ofc_partipoorden: ParTipoOrden, ofc_idordenpago: IdOrden}]; $grid.jqGrid('addRowData', id, mydata[0], "first"); $grid.jqGrid("editRow", id, true, '', '', '', '', reload); }}); }); </code></pre> <p><strong>UPDATE</strong> Oleg this is code that contains Jquery UI Autocomplete: In the return the value "Autorizacion" is <strong>id: item.ofr_ultimaauto</strong> in the autocomplete function "ListaProveedores" the value of "Autorizacion" item.id This form is for fast filling of bills (taxes) The grid is not from the searching toolbar. When select value from autocomplete how I can copy id: item.ofr_ultimaauto to column "Autorizacion"?</p> <blockquote> <pre><code>function getData(request, response) { $.ajax({ url: '@Url.Action("BuscaRazonSocial", "raFacturaCompra", new { area = "Operacion" })', type: 'GET', dataType: 'json', data: { term: request.term, maxResult: 20 }, success: function (data) { response($.map(data, function (item) { return { label: item.ofr_nit, value: item.ofr_nit, id: item.ofr_ultimaauto, desc: item.ofr_razon }; })) } }); } function ListarProveedores(elem) { $(elem).autocomplete({ source: getData, minLength: 5, autosearch: true, select: function (event, ui) { $(elem).val(ui.item.value); $(elem).focus().trigger({ type: 'keypress', charCode: 13 }); } }).data("ui-autocomplete")._renderItem = function (ul, item) { return $("&lt;li&gt;") .append("&lt;a class='ui-menu-item-titulo'&gt;&lt;strong&gt;" + item.label + "&lt;br&gt;" + item.desc + " - &lt;/strong&gt;" + item.id + "&lt;/a&gt;") .appendTo(ul); }; } </code></pre> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload