Open bianweiall opened 10 years ago
代码如下:
BUI.use(['bui/grid', 'bui/data', 'bui/toolbar'], function(Grid, Data, Toolbar) { var Grid = Grid, Store = Data.Store, columns = [{ title: '物品编号', dataIndex: '_number', width: '25%' }, { title: '名称', dataIndex: '_name', width: '25%' }, { title: '数量', dataIndex: '_quantity', width: '25%' }, { title: '数量单位', dataIndex: '_quantityunit', width: '25%' }]; var store = new Store({ url: "/green/goods/list/4", autoLoad: true, remoteSort: true, pageSize: 1, proxy: { method: 'post', dataType: 'json' } }); var grid = new Grid.Grid({ render: '#my-table', columns: columns, store: store, width: '100%', forceFit: true, plugins: [Grid.Plugins.CheckSelection], tbar: { items: [{ btnCls: 'button button-small', text: '<i class="icon-plus"></i>添加', listeners: { 'click': function() {} } }, { btnCls: 'button button-small', text: '<i class="icon-remove"></i>删除', listeners: { 'click': function() {} } }] } }); var bar = new Toolbar.NumberPagingBar({ render: '#my-table-nav', elCls: 'pagination pull-right', store: store }); bar.render(); grid.render(); var tbar = grid.get('tbar'), searchBar = new Toolbar.Bar({ elCls: 'pull-right', items: [{ content: '<input name="name" id="id"/>' }, { xclass: 'bar-item-button', btnCls: 'button button-small button-primary', text: '搜索' }] }); tbar.addChild(searchBar); });
width: '100%', forceFit: true,不要放到一起,列已经按照百分比计算了,就不要用forceFit了
代码如下: