ExtJS 4 - 如何禁用“下一步” & “最后”当网格中没有记录时,分页工具栏中的图标?
我有一个网格,底部带有分页工具栏,顶部有一个“加载”按钮,可以用于加载网格中的记录。
因此,最初网格中不存在任何值,但在这种情况下,分页工具栏也会显示第 1 页(共 1 页),并且还会启用转到“下一页”或“最后一页”的图标。 >
因此,当用户单击任何这些图标时,虽然记录未加载,但内部“page”和“start”的值设置为 NaN,如果用户单击“Load”按钮,则这些 NaN值被传递到服务器,这不是预期的。
也就是说,理想情况下,它应该传递 page=0&start=0,而传递 page=NaN&start=NaN。服务器无法识别这些值并抛出错误。
对此的一个快速解决方法是修改服务器端的代码,但目前这超出了我们团队工作的范围,因此我想知道如何实现以下目标:
问)如何禁用“下一步” , 当网格没有记录时分页工具栏上的“最后”图标?
或者,
问)如何在加载商店之前修改“页面”和“开始”变量的值,以便我们可以传递 0而不是 NaN?
我尝试在网格存储的 beforeload 事件中访问这些参数,但在那里我可以找到诸如 startParam 或 pageParam 之类的属性 - 显示参数名称,但找不到任何访问/修改这些值的方法。
有人对此有什么想法吗?
提前致谢。
PS:使用的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.
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.
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.
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) How to disable 'next', 'last' icons at paging toolbar when the grid has no records?
Or,
Q) How to modify the values of 'page' and 'start' variables before loading the store so that we can pass 0 instead of NaN?
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.
Does anyone have an idea on this?
Thanks in advance.
PS: ExtJS Version used is 4.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种可能的解决方案是使用
store.load(); 来代替。
第二种可能的解决方案是使工具栏初始禁用并在加载数据时启用它:
One possible solution could be using
instead of
store.load();
.The second possible solution is to make toolbar initialy disabled and enable it when data is loaded:
检查响应的总计数,如果当网格为空时它不返回零,那么就会发生此类错误。
check the total count in response, if it is not returning zero when your grid is empty then such errors will occur.