项目中用到jquery easyui,用到了DataGrid拼接table,记录一个例子:
- function setProductData(){
- var rows = $("#commonProductListTable").datagrid("getSelections");
- var proArray = new Array();
- for(var i in rows){
- var a = {
- chk:rows[i]['productId'],
- productCode:rows[i]['productCode'],
- productName:rows[i]['productName'],
- shopName:rows[i]['shopName'],
- categoryName:rows[i]['categoryName'],
- state:rows[i]['state'],
- isVirtual:rows[i]['isVirtual'],
- productType:rows[i]['productType']
- };
- proArray.push(a);
- }
- $("#setdata").datagrid({
- columns:[[
- {field:'chk',checkbox:'true',width:'50'},
- {field:'productCode',title:'商品编号',editor:'text',width:'150'},
- {field:'productName',title:'商品名称',editor:'text',width:'250'},
- {field:'shopName',title:'店铺名称',editor:'text',width:'150'},
- {field:'categoryName',title:'商品分类',editor:'text',width:'180'},
- {field:'state',title:'商品状态',editor:'text',width:'100'},
- {field:'isVirtual',title:'是否为虚拟商品',editor:'text',width:'100'},
- {field:'productType',title:'热门标签',editor:'text',width:'100'}
- ]]
- }).datagrid('loadData',proArray).datagrid('acceptChanges');
- }
- 首先,获取所有选中行,取出其中的属性值拼成新的row,然后在需要显示数据的地方将新的row拼出来。