`

gqgrid出现批量选择显示dialog框中数据未加载问题

阅读更多

 

工作上遇到的棘手的问题,查看半天文档已经网上解决方案(几乎都不对),总结如下:

1,$('#tabs-1 #batch_on_sale,#batch_on_sale_by_store').live('click',function(){

        var target = $(this);

        var checkbox_checked = $("#whitelist tr[aria-selected='true']");

        var product_ids = '';

        var product_batch_box = $("#product_batch_box");

        var product_shop_batch_box = $("#product_shop_batch_box");

        var title = target.attr('title');

        var type = target.attr('type');

        if(checkbox_checked.length > 0){

            checkbox_checked.each(function(){

                var value = $(this).attr('id')+',';

                product_ids += value;

            });

            product_ids = product_ids.substring(0, product_ids.length-1);   

        }else{

            alert('<?php echo __('Please Select Products')?>');

            return;

        }

        if(type == 'product'){

        product_batch_box.dialog({

                title:title,

                modal: true,

                autoOpen: false,

                width: 320,

                buttons: {

                    '<?php echo __('Confirm');?>':function(){

                        var status = $('input[name="status"]:checked').val();

                        console.log(status);

                        window.location.href = 'product/batch_on_sale?product_ids='+product_ids+'&status='+status;

                    },

                    '<?php echo __('Cancel');?>':function(){

                    product_batch_box.dialog('close');

                    }

                }

            });

            product_batch_box.dialog('open');

            return false;

        }else if(type == 'store'){

        var obj = $(this);

        var _tb_list = $("#product_shop_tb");

            var sid = "";

        //show modal

            product_shop_batch_box.dialog({

                title:'店铺(微店)产品上下架',

                modal: true,

                autoOpen: false,

                width: 850,

                height:700

            });

            product_shop_batch_box.dialog('open');

            //grid:loading selected products' related info

            _tb_list.jqGrid({

                url: 'product/batch_info?product_ids='+product_ids+'&status='+status,

                datatype: 'json',

                mtype: 'post',

                postData: {

                    'product_id': function() { return product_id; },

                    'type' : function (){ return '0'}

                },

                colNames:['产品ID','<div style="text-align:center;"><input type="checkbox" value=""/></div>','产品名称','店铺名称','上架'],

                colModel:[

                    {name:'product_id',index:'product_id', align:"center",width:100,sortable:false,stype:false},      

                    {

                    name:'product_id',

                        index:'product_id',

                        stype:false,

                        width:100,

                        formatter:function(cellValue, options, rowObject){

                            var html = '';

                            html = '<div style="text-align:center;"><input type="checkbox" value=""/></div>'; 

                            return html;

                        },

                        sortable:false,

                    },

                    

                    {name:'product_name',index:'product_name', align:"center",width:400,sortable:false,stype:false},

                    {name:'shop_name',index:'shop_name', align:"center",width:200,sortable:false,stype:false},

                    {

                        name:'product_on_sale',

                        index:'product_on_sale',

                        align:"center",

                        width:100,

                        formatter:function(cellValue, options, rowObject){

                            var html = '<div style="display:none">'+rowObject.product_id+'_'+rowObject.shop_id+'</div>';

                            if(rowObject.on_sale == 'Y'){

                            html += '<img src="/statics/images/icons/tick.png" alt="Active" class="active_img" style="cursor:pointer;">'; 

                            }else{

                            html += '<img class="active_img" alt="Invalid" src="/statics/images/icons/cross0.png" style="cursor:pointer;">'; 

                            }

                             

                            return html;

                        },

                        sortable:false,

                        stype:false,

                     }

                ],

             

                caption: '',

                sortable: true,

                rowNum: 20,

                rowList: [10,20,30],

                pager: '#pager_score',

                height: '100%',

                rownumbers:true,

                autowidth: true,

                viewrecords: true,

                sortname: 'product_id',

                sortorder: 'desc',

                jsonReader: {

                    root: 'rows',

                    total: 'total',

                    page: 'page',

                    records: 'records',

                    repeatitems: false,

                    cell: 'cell',

                    id: 'id',

                    userdata: 'productdata'

                },

             

            }).setGridParam({url: 'product/batch_info?product_ids='+product_ids+'&status='+status,}).trigger('reloadGrid');

        }else{

            alert('<?php echo __('Net worng');?>');

        } 

 

2,setGridParam({url: 'product/batch_info?product_ids='+product_ids+'&status='+status,}).trigger('reloadGrid');我们直接在加载.trigger('reloadGrid');不会出现dialog框中再次显示的内容刷新,我们需要setGridParam({url: 'product/batch_info?product_ids='+product_ids+'&status='+status,}) again,这样就重新加载新的内容,具体的看gqgrid文档

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics