0

Visual Studio 2010 Asp.Net MVC4 と jqGrid を使用したプロジェクトに取り組んでいます。オートコンプリートを展開し、ユーザーが値を選択すると、この問題を解決するために値を別のセルにコピーする必要がありますか? 画像とコードを添付しました。 ここに画像の説明を入力

これは私のコードです。オートコンプリートは機能します。オートコンプリートから別のセルに値をコピーするにはどうすればよいですか?

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);
        }});
});

UPDATE Oleg これは Jquery UI オートコンプリートを含むコードです: 戻り値の "Autorizacion" はid です:オートコンプリート関数 "ListaProveedores" の item.ofr_ultimaauto "Autorizacion" の値 item.id このフォームは請求書の迅速な記入用です (税) グリッドは検索ツールバーからのものではありません。オートコンプリートから値を選択するときに、id: item.ofr_ultimaauto を列 "Autorizacion" にコピーするにはどうすればよいですか?

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 $("<li>")
        .append("<a class='ui-menu-item-titulo'><strong>" + item.label + "<br>" + item.desc + " - </strong>" + item.id + "</a>")
        .appendTo(ul);
    };  
}
4

1 に答える 1