首先先来看一下,直接从后台读取数据并展示到前端的列表,后端传回的数据是“按商品ID倒序排列”
前端源代码
1 $('#good_tables').datagrid({ 2 nowrap: true, 3 autoRowHeight: true, 4 striped: true, 5 fitColumns: true, 6 collapsible: true, 7 url: 'xxx', 8 border: false, 9 idField: 'id', 10 selectOnCheck: true, 11 singleSelect: true, 12 width:'100%' , 13 resizable:true, 14 columns: [[ 15 { 16 field: 'id', 17 title: '商品ID', 18 width: 60, 19 align: 'center', 20 formatter: function (value) { 21 return value+""; 22 } 23 }, 24 { 25 field: 'goodsName', 26 title: '商品名称', 27 width: 120, 28 align: 'center', 29 formatter: function (value) { 30 return value; 31 } 32 }, 33 { 34 field: 'activity_do', 35 title: '操作', 36 width: '15%', 37 align: 'center', 38 formatter: function (value, row) { 39 return'<a href="javascript:delGoods(' + row.id +')" style="color: red">删除</a>'; 40 } 41 } 42 ]], 43 pagination: true, 44 pageSize: 10, 45 rowNumbers: false 46 });