ExtJS 4 - 如何禁用“下一个”&当网格中没有记录时,页面工具栏中的“最后”图标? [英] ExtJS 4 - How to disable 'next' & 'last' icons in the paging toolbar when no records present in grid?

查看:132
本文介绍了ExtJS 4 - 如何禁用“下一个”&当网格中没有记录时,页面工具栏中的“最后”图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有底部有寻呼工具栏的网格和顶部的加载按钮,可用于在网格中加载记录。

I have a grid with paging toolbar at the bottom and a 'Load' button at the top which can be used to load records in the grid.

因此,最初,网格中没有值,但是在这种情况下,分页工具栏也显示第1页,还有图标要去启用下一个或最后页面。

Thus, initially there are no values present in the grid, but in such condition too the paging toolbar displays Page 1 of 1, and also the icons to go to 'next' or 'last' page are enabled.

由于这一点,当用户点击任何这些图标时,尽管记录不是加载但内部的页面和开始的值设置为NaN,如果用户单击加载按钮,那么这些NaN值将被传递到不是预期的服务器。

Due to this, when user clicks any of these icons, then, though the records are not loaded but internally the values of 'page' and 'start' are set as NaN and if then user clicks at 'Load' button then these NaN values get passed to the server which is not what is expected.

也就是说,理想情况下,它应该传递page = 0& start = 0,因为它传递page = NaN& start = NaN。服务器无法识别这些值并抛出错误。

That is, ideally, it should pass page=0&start=0 where as it passes page=NaN&start=NaN. The server doesn't recognize these values and throws error.

一个快速解决方案是修改服务器端的代码,但目前超出了范围我的团队工作,因此我想知道如何可以追求:

One quick fix for this is the modification of the code at the server side, but currently that is beyond the scope of our team work and thus I was wondering that how could following be acheived:

Q)如何禁用下一个,最后图标在分页工具栏当网格没有记录?

或者,

Q)如何在加载存储之前修改页面和开始变量的值,以便我们可以传递0而不是NaN?

我尝试访问这些参数在网格存储的beforeload事件中,但是我可以找到像 - startParam或pageParam这样的属性 - 显示参数的名称,但找不到任何访问/修改值的方法。

I tried accessing these parameters in beforeload event of the grid store, but there I could find the properties like - startParam or pageParam - displaying the name of parameter, but couldn't locate any method of accessing/modifying there values.

有没有人有这个想法?

提前感谢

PS:使用的ExtJS版本为4。

PS: ExtJS Version used is 4.

推荐答案

一个可能的解决方案可能是使用

One possible solution could be using

store.loadPage(1);

而不是 store.load();

第二个可能的解决方案是禁用工具栏初始化,并在数据加载时启用它:

The second possible solution is to make toolbar initialy disabled and enable it when data is loaded:

var grid = Ext.create('Ext.grid.Panel', {
    // ...
    store: store,
    dockedItems: [{
        xtype: 'pagingtoolbar',
        store: store,
        dock: 'bottom',
        disabled: true
    }]
});
store.on('load', function(){
  grid.down('pagingtoolbar').enable();
});

这篇关于ExtJS 4 - 如何禁用“下一个”&当网格中没有记录时,页面工具栏中的“最后”图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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