【问题标题】:I need to add a button show all records in the grid我需要添加一个按钮来显示网格中的所有记录
【发布时间】:2019-02-07 09:24:30
【问题描述】:

单击底部停靠的分页工具栏上的全部显示按钮时,我需要在网格中显示所有记录。

尝试使用参数添加负载,但网格不会刷新所有记录。

你能帮我解决我在这方面还缺少什么吗?

ds.load({params:{start:0,limit:iCnt }});

上面试过了,还是不行

grid.addDocked({
        xtype: 'pagingtoolbar',
        dock: 'bottom',
        pageSize: 50,  //maxRowCnt,//Pagesize set
        store: grid.getStore(),//Grid's store set
        displayInfo: true,//Display the records information
        displayMsg: 'Displaying Records {0} - {1} of {2}',
        emptyMsg: "No records to display",
        items: [
        {
            pressed: false,
            enableToggle:false,
            cls: 'x-btn-text',
            text: 'Show All',
            tooltipType: 'title',
            tooltip: ' Show all records ',
            handler:showAllFunc
        }]
    });


showAllFunc = function() {
    var grid = ColdFusion.Grid.getGridObject("mainGrid");
    var ds = grid.getStore();
    var iCnt = ds.getTotalCount();
    ds.load({params:{start:0,limit:iCnt }});
    grid.getView().refresh();
    grid.getDockedItems('toolbar[dock="bottom"]')[1].updateInfo();
}

【问题讨论】:

  • 你必须更新pageSize
  • 试过这个 ds.pageSize=iCnt,唯一改变的是 displayMsg,但网格不会刷新以显示所有项目。
  • 张贴fiddle,说明您目前为止所尝试的内容。
  • 剂量你的 ds.load 触发 ajax 请求?之后后端的响应是什么样的?
  • 我终于想通了,要更新底部的分页工具栏,要更新商店的pagesize ds.pageSize=iCnt; Moataz 正确地指出,我的 ajax 请求将只更新页面大小甚至 ds.load({params:{start:0,limit:iCnt }});开始和限制不会有所作为。意识到在我的情况下,我必须更新我的页面大小参数 ds.load({params:{pageSize:iCnt}});

标签: extjs coldfusion extjs4 extjs4.2 coldfusion-2018


【解决方案1】:

这是我几年前研究的一个 JS 解决方案。我为内嵌文档保留了一些参考资料。

//get the grid Object
grid = ColdFusion.Grid.getGridObject('myGrid'); //your grid name

//Call the function to add record count to the grid
gridFooter(grid);

//Modify grid footer to display record count
//See http://docs.sencha.com/ext-js/3-4/#!/api/Ext.PagingToolbar-cfg-prependButtons for more details.
var gridFooter = function()
{   //modified from 
//http://www.thecfguy.com/post.cfm/showing-record-information-in-cfgrid-footer-in-coldfusion-9

//overwrite existing grid footer with new div, Ext.id() will assign unique id to footer
var bbar = Ext.DomHelper.overwrite(grid.bbar,{tag:'div',id:Ext.id()},true);

//Create new PagingToolbar and render it to bbar (grid footer)
gbbar = new Ext.PagingToolbar({
    renderTo:bbar,
    store: grid.store, 
    pageSize: pgSize,
    displayMsg: 'Showing {0} - {1} out of {2} records',
    emptyMsg: '<b style="color:red">No Records Found</b>',
    displayInfo: true
});

}

【讨论】:

    猜你喜欢
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 2011-10-03
    • 2020-11-29
    • 2011-04-23
    • 1970-01-01
    • 1970-01-01
    • 2014-04-24
    相关资源
    最近更新 更多