ExtJS4.2网格过滤器使用分页功能留空行-NewbieQ [英] ExtJS4.2 Grid Filter Leaves empty Rows with Paging - NewbieQ

查看:71
本文介绍了ExtJS4.2网格过滤器使用分页功能留空行-NewbieQ的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了各种刷新网格的方法,但是我尝试的所有方法都不起作用.我要刷新网格还是要加载商店???您可以看到分页工具栏在过滤后仍显示50页.如果给定的分页上没有日期,并且它为空,则它将禁用工具栏,并且在该页面之后分页不起作用,除非您刷新浏览器并跳过空白页.因此,在我的情况下,第15页没有行,因此当您单击下一步并获得该页面时,它会中断.如果您键入页码16,那么一切都很好,直到您打到另一个人的空白页为止. 我的日期选择器在下面的视口中,并且我尝试过刷新网格并加载商店以及其他可能导致未定义错误的事情.不知道从哪里开始,所以我将在下面显示我的代码和屏幕截图:

I have tried various ways to refresh the grid but everything I try doesn't work. Do I refresh the Grid or do I load the store??? You can see that the paging tool bar is still showing 50 pages after the filtering. If there are no dates on a given pag and it is empty then it will disable the tool bar and paging doesn't work after that page un less you refresh the browser and skip over the empty page. So, in my case page 15 has no rows so it breaks when u hit next and get that page. If you type in the page number 16 then all is good until you hit another's empty page. My datepicker is in my viewport below and I have tried refreshing the gird and loading the store as well as other things which mostly result in undefined error. Not sure where to start with this one so I will show my code and screen shots below:

选择日期之前:

BEFORE DATE SELECTION:

日期选择后:

AFTER DATE SELECTION:

商店:

STORE:

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
autoLoad: true,
autoSync:true,
pageSize:50,
proxy:
{
    type: 'ajax',

     //extraParams :{limit:1000},

    api:
    {
        read: 'http://192.168.0.103/testit/dao_2.cfc?method=getContent',
        update: 'http://192.168.0.103/testit/dao_2-post.cfc?method=postContent'
    },
    reader:
    {
        type: 'json',
        root: 'data',
        successProperty: 'success',
        totalProperty : 'dataset',
        remoteFilter : true
    },
    listeners:
    {
        // stuff goes here maybe??

    }
}   
});

网格面板:

GRID PANEL:

Ext.define('AM.view.user.List' ,{
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
title: 'All Users',
store: 'Users',
//buffered: true,
plugins:[Ext.create('Ext.grid.plugin.RowEditing', {clicksToEdit: 2})],
dockedItems: [{ xtype: 'pagingtoolbar',
                store: 'Users',
                dock: 'bottom',
                displayMsg: 'Displaying Records {0} - {1} of {2}',
                displayInfo: true}],


initComponent: function() {

    this.columns = [
                    Ext.create('Ext.grid.RowNumberer',
                        {
                        resizable: true,
                        resizeHandles:'all',
                        align: 'center',
                        minWidth: 35,
                        maxWidth:50
                        }),
                    {
                    header: 'Name',
                    dataIndex: 'message_id',
                    flex: 1,
                    editor:'textfield',
                    allowBlank: false,
                    menuDisabled:true
                    },
                    {
                    header: 'Email',
                    dataIndex: 'recip_email',
                    flex: 1,
                    editor:'textfield',
                    allowBlank: false,
                    menuDisabled:true
                    },
                    {
                    header: 'Date Time',
                    dataIndex: 'unix_time_stamp',
                    width: 120,
                    menuDisabled:true,
                    // submitFormat: 'd/m/Y',
                    renderer: Ext.util.Format.dateRenderer('m/d/Y'),
                    field:{ xtype:'datefield',
                            autoSync:true,
                            allowBlank:false,
                            editor: new Ext.form.DateField(
                                    {format: 'm/d/y'})  }
                    }];


    this.callParent(arguments);

},

});

视口:

VIEWPORT:

Ext.Loader.setConfig({enabled:true});

Ext.application({
requires: ['Ext.container.Viewport'],
name: 'AM',
appFolder: 'app',
controllers: ['Users'],

launch: function() {

    Ext.create('Ext.container.Viewport', {
    layout: 'border',
    items:[{
            region: 'center',
            itemId:'centerPanelRegion',
            title:'The Title',
            xtype: 'tabpanel',
            hidden: true,
            activeTab: 0,
            items:[{
                    xtype: 'userlist',
                    listeners:
                    {
                        select: function(selModel, record, index, options)
                        {
                            // do something with the selected date
                            console.log('select');
                        },
                        add: function(selModel)
                        {
                            // do something with the selected date
                            console.log('add - init2.js');
                        },
                        afterrender:function(selModel)
                        {
                            // do something with the selected date
                            console.log('afterrender - userlist(init2.js)');
                        },
                        beforerender:function(selModel)
                        {
                            // do something with the selected date
                            console.log('beforerender - userlist(init2.js)');
                        }
                    }
                  }]
            },
            {
            region: 'west',
            itemId:'westPanelRegion',
            hidden: true,
            layout:'fit',
            xtype: 'tabpanel',
            activetab:0,
            collapsible:false,
            split: false,
            title: 'The Title',
            width:178,
            maxWidth:400,
            height: 100,
            minHeight: 100,
            items:[{
                    title: 'Tab 1',
                    xtype:'panel',
                    items:
                        [{
                        xtype: 'datepicker',
                        itemId:'datePickerFld',
                        listeners:{
                            beforerender: function(){
                                console.log('datepicker - beforerender(init2.js)');
                                var store = Ext.getStore('dates');
                                store.load({callback: function(){
                                console.log('datepicker - callback(init2.js');
                                console.log(store.data.items[999].data.recip_email);
                                console.log(store.data.items[999].data.unix_time_stamp);
                                }
                                })
                            }
                        },

                        handler: function(picker, date)
                            {
                            // do something with the selected date
                            console.log('date picker example in init2.js' + Ext.Date.format(date,'m/d/Y'));

                            // get store by unique storeId
                            var store = Ext.getStore('Users');

                            // clear current filters
                             store.clearFilter(true);

                            // filter store
                            Ext.encode(store.filter("unix_time_stamp", Ext.Date.format(date,'m/d/Y')));

                            //store.load();
                            //store.sync();

                            }
                        }]
            },
            {
                title: 'Tab 2',
                html: 'ers may be added dynamically  - Others may be added dynamically',
            }]

         }]
    });
}
});

控制器:

CONTROLLER:

Ext.define('AM.controller.Users', {
extend: 'Ext.app.Controller',
stores:['Users', 'dates'],
models:['User', 'date'],
views: ['user.List','user.Edit'],


init: function() {

    Ext.getStore('dates').addListener('load',this.ondatesStoreLoad, this);

    this.control(
    {

        'viewport > userlist':
        {
            itemdblclick: this.editUser,
        },

        'useredit button[action=save]':
        {
            click: this.updateUser
        }           

    });

},


// ----------  handler Function declarations  -------------

ondatesStoreLoad: function(me,records,success)
{

// ------  Gets the dates from dates store and loads an array
var store = this.getStore('dates');
sendDataArray = [];

store.each(function(record){
    var recordArray = [record.get("unix_time_stamp")];
    sendDataArray.push(recordArray);
});         


// ------  Set DatePicker Bullshit right fucking here  --------//

var dtFld = Ext.ComponentQuery.query('#datePickerFld')[0];

dtFld.setDisabledDates(["^(?!"+sendDataArray.join("|")+").*$"]);
dtFld.setMaxDate(new Date());
dtFld.setMinDate(new Date('05/01/2013'));


var wstPnlReg = Ext.ComponentQuery.query('#westPanelRegion')[0];
wstPnlReg.show();

var ctrPnlReg = Ext.ComponentQuery.query('#centerPanelRegion')[0];
ctrPnlReg.show();

// var grid = Ext.widget('userlist');

},

onUsersStoreDataChange: function(me)
{
    //console.log('Hey the store data just changed!');
},

editUser: function(grid, record)
{
    var view = Ext.widget('useredit');
    view.down('form').loadRecord(record);
},

updateUser: function(button)
{
    var win    = button.up('window'),
        form   = win.down('form'),
        record = form.getRecord(),
        values = form.getValues();

    record.set(values);
    win.close();
    this.getUsersStore().sync();
},

});

更新的视口: :仅在日期选择器处理程序中进行的更改

UPDATED VIEWPORT: Changes made only in datepicker handler

Ext.Loader.setConfig({enabled:true});

Ext.application({
requires: ['Ext.container.Viewport'],
name: 'AM',
appFolder: 'app',
controllers: ['Users'],

launch: function() {

    Ext.create('Ext.container.Viewport', {
    layout: 'border',
    items:[{
            region: 'center',
            itemId:'centerPanelRegion',
            title:'The Title',
            xtype: 'tabpanel',
            hidden: true,
            activeTab: 0,
            items:[{
                    xtype: 'userlist',
                    listeners:
                    {
                        select: function(selModel, record, index, options)
                        {
                            // do something with the selected date
                            console.log('select');
                        },
                        add: function(selModel)
                        {
                            // do something with the selected date
                            console.log('add - init2.js');
                        },
                        afterrender:function(selModel)
                        {
                            // do something with the selected date
                            console.log('afterrender - userlist(init2.js)');
                        },
                        beforerender:function(selModel)
                        {
                            // do something with the selected date
                            console.log('beforerender - userlist(init2.js)');
                        }
                    }
                  }]
            },
            {
            region: 'west',
            itemId:'westPanelRegion',
            hidden: true,
            layout:'fit',
            xtype: 'tabpanel',
            activetab:0,
            collapsible:false,
            split: false,
            title: 'The Title',
            width:178,
            maxWidth:400,
            height: 100,
            minHeight: 100,
            items:[{
                    title: 'Tab 1',
                    xtype:'panel',
                    items:
                        [{
                        xtype: 'datepicker',
                        itemId:'datePickerFld',
                        listeners:{
                            beforerender: function(){
                                console.log('datepicker - beforerender(init2.js)');
                                var store = Ext.getStore('dates');
                                store.load({callback: function(){
                                console.log('datepicker - callback(init2.js');
                                console.log(store.data.items[999].data.recip_email);
                                console.log(store.data.items[999].data.unix_time_stamp);
                                }
                                })
                            }
                        },

                        handler: function(picker, date)
                            {
                                // do something with the selected date
                        console.log('date picker example in init2.js' + Ext.Date.format(date,'m/d/Y'));

                        // get store by unique storeId
                            var store = Ext.getStore('Users');

                            // clear current filters
                             store.clearFilter(true);

                            // filter store
                            store.filter("unix_time_stamp", Ext.Date.format(date,'m/d/Y'));

                        // Load the store
                        store.load();


                            }
                        }]
            },
            {
                title: 'Tab 2',
                html: 'ers may be added dynamically  - Others may be added dynamically',
            }]

         }]
    });
}
});

推荐答案

此行可能会引起问题.

Ext.encode(store.filter("unix_time_stamp", Ext.Date.format(date,'m/d/Y')));

我不确定为什么要在store.filter返回的任何值上调用Ext.encode,但是我认为您不想这样做(这很可能导致undefined错误).

I'm not sure why you are calling Ext.encode on whatever store.filter returns, but I don't think you want to do that (and it is likely causing the undefined errors).

对于不更新当前计数的分页工具栏,更新存储时您可能没有在服务器响应中返回正确的信息.服务器响应应包括记录总数.根据Ext.toolbar.Paging的文档, http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.toolbar.Paging :

As for the paging toolbar not updating the current count, it is likely you just aren't returning the correct information in your server response when updating the store. The server response should include the total number of records. According to the docs for Ext.toolbar.Paging, http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.toolbar.Paging:

从服务器发送回的数据包具有以下形式:

The packet sent back from the server would have this form:

{
    "success": true,
    "results": 2000,
    "rows": [ // ***Note:** this must be an Array
        { "id":  1, "name": "Bill", "occupation": "Gardener" },
        { "id":  2, "name":  "Ben", "occupation": "Horticulturalist" },
        ...
        { "id": 25, "name":  "Sue", "occupation": "Botanist" }
    ]
}

这篇关于ExtJS4.2网格过滤器使用分页功能留空行-NewbieQ的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆