求教easyui datagrid如何动态生成列
展开全部
态产列代码其实按datagrid所需列json格式拼凑字符串实现列合并 //用字符串产grid所需列 function AddColspanGridColumn(fieldName, title, width, align, rowStyle, formatterStyle,colspan) { var columnStr = ""; //Easyuidatagrid列基本格式 columnStr = "{field: '" + fieldName + "', title: '" + title + "', width: " + width; //齐式 if (align != "" && align != null && align != undefined) columnStr += ",align:'" + align + "'"; //否合并列 if (colspan != 0 && colspan != "" && colspan != null && colspan != undefined) columnStr += ",colspan:" + colspan; //否需要行式 if (rowStyle != "" && rowStyle != null && rowStyle != undefined) columnStr += ",styler: function (val, row, index) {return '" + rowStyle + "';}"; if (formatterStyle != "" && formatterStyle != null && formatterStyle != undefined) columnStr += ",formatter: function (val, row, index) {" + "if (val == '' || val == undefined) val = '0';" + "return \"\"+val+\"\";}"; columnStr += "}"; return columnStr; } 产json字符串给datagrid, var options = $("#" + gridName).datagrid("options"); var columnstr = AddColspanGridColumn("AVG_PRICE", "户均价", 80, "left", "background-color:#F6B03E;", "font-size:14px;font-weight:bold;", 0) options.columns = eval(columnstr); 设置列内容超链接参考函数formatter,设置列内
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询