首先返回到页面的需要是JSON数据:

  第一步:

  遍历表头,插入到array中

for (var i = 0; i < jsonObj.title.length; i++) {
                            //把返回的数据封装到一个对象中
                            var col = {}
                            col['title'] = jsonObj.title[i].TITLE;
                            col['field'] = jsonObj.title[i].FIELD;
                            col['width'] = 100;
                            col['align'] = 'center'
                            //把这个对象添加到列集合中
                            columnsAll.push(col);
                        }

  第二步:

  初始化表格并加载数据

  

$('#dataGrid_12').datagrid({
                         title:'CAF产销存数据下发',
                            width:  'auto',
                            height: "200",
                            nowrap: true,
                            striped: false,
                            border: true,
                            collapsible:false,//是否可折叠的
                            fit: true,//自动大小
                            remoteSort:false,  
                            idField:'ID',
                            pagination:true,//分页控件
                            rownumbers:true,//行号
                            queryParams: form2Json("queryForm2"),
                            frozenColumns:[[
                            {title:'统计项',field:'items',checkbox:false}
                        ]],  
                            method: 'get',
                            columns: [columnsAll],
                        }).datagrid('loadData', { total: 30, rows: [] });

 

                       

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
  • 2021-08-30
  • 2022-01-22
猜你喜欢
  • 2021-05-18
  • 2021-11-18
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案