将id变成内容

https://blog.csdn.net/qq_36299991/article/details/101032619

写成script

, {field: 'brandId', title: '品牌ID', width: 120,templet:'<div>{{sotitle(d.brandId)}}</div>'}

    //将id变成内容,应用template模板
    function sotitle(brandId){
        var bId = brandId;
        var title;
        $.ajax({
            url:'/showallbrand',//你的后台请求路径
            dataType:'json',
            async: false,//同步
            success:function(data){
                    $.each(data,function (index, obj) {
                        if(obj.brandId==bId){
                            title=obj.brandName;
                            //console.log(obj.brandId,obj.brandName);
                        }
                    });
            }
        });
        return title;
    };

 

posted @ 2022-10-24 16:33  星云惊蛰  阅读(31)  评论(0)    收藏  举报