本文介绍了具有复合键的Yii2模态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

任何人都可以帮我复合键吗?我无法正常运作。

Can anyone help me with the composite key? I am not able to function properly.

function init_click_handlers(){
  $(".button-endereco").click(function(e) {
            var fcodigo = $(this).closest("tr").data("codigo");
            var fcodigopessoa = $(this).closest("tr").data("codigopessoa");
            var map = {codigo: $(this).closest("tr").data("codigo"), codigopessoa: $(this).closest("tr").data("codigopessoa")};
            $.get(
                "update ",
                {
                    codigo: fcodigo
                    codigopessoa: fcodigopessoa
                },
                function (data)
                {
                    $("#endereco-modal").find(".modal-body").html(data);
                    $(".modal-body").html(data);
                    $("#endereco-modal").modal("show");
                }
            );
        });

}

init_click_handlers(); //first run
$("#endereco_id").on("pjax:success", function() {
  init_click_handlers(); //reactivate links in grid after pjax update
});

$url = Yii::$app->urlManager->createUrl('../endereco/update?codigo='.$dataProvider->codigo.'&codigopessoa='.$dataProvider->codigopessoa);


推荐答案

[100%工作]终于明白了,对于那些谁想要使用带有复合键的Gridview(kartik)跟随代码:

[100% working] Finally got it, for those who want to use the Gridview (kartik) with composite key follows the code:

function init_click_handlers(){
  $(".button-endereco").click(function(e) {
             chave = $(this).closest("tr").data("key");
             $.ajax({
                url: "'.Yii::$app->urlManager->createUrl('endereco/update').'",
                type: "GET",
                data: {"codigo": parseInt(chave["codigo"]), "codigopessoa":parseInt(chave["codigopessoa"])},
                //data: {keylist: parseInt(keys)},
                dataType: "html",
                success: function(data) {
                        $("#endereco-modal").find(".modal-body").html(data);
                        $(".modal-body").html(data);
                        $("#endereco-modal").modal("show");
                }
            });
        });
}

init_click_handlers(); //first run
$("#endereco_id").on("pjax:success", function() {
  init_click_handlers(); //reactivate links in grid after pjax update
});

这篇关于具有复合键的Yii2模态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 19:25