dxq613 / bui

基于jQuery,兼容KISSY 的富客户端控件库
646 stars 359 forks source link

Grid表头和单元格宽度不一样 #182

Open bianweiall opened 10 years ago

bianweiall commented 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);
 });
dxq613 commented 10 years ago

width: '100%', forceFit: true,不要放到一起,列已经按照百分比计算了,就不要用forceFit了