extjs 4.1.1 - 本地数据的网格分页(extjs 4.1.1 - Pagination in grid on local data)
我对extjs比较陌生。 我遇到了一个我无法解决的问题。 我一直在网上搜索但无法找到答案。 感谢任何帮助。
在我的代码中,我试图为网格上显示的数据添加分页。 代码对服务器进行ajax调用以获取数据。 服务器发送的数据超出了需要。 因此,客户端提取响应文本(json)的一部分,并将其显示在网格面板中。
网格显示数据正常。 但是分页不起作用。 它总是显示“0页0”和“无数据显示”。
但是,如果我用硬编码数据替换数据,并使用硬编码数据创建存储和网格,则分页有效。 因此,在创建商店和网格时,我似乎已经拥有了数据。
这是简化的代码。 使用myStore1 / myData1(硬编码数据)时,分页工作。 将myStore1和myData1替换为从服务器检索数据后加载的myStore2和myData2,分页不起作用。
我在网上看到的所有例子都涉及硬编码数据...感谢任何见解或指针。
Ext.Loader.setConfig({ enabled: true }); Ext.Loader.setPath('Ext.ux', 'ext-4.1.1/examples/ux'); Ext.require('Ext.ux.data.PagingMemoryProxy'); Ext.application({ name: 'MS GUI', launch: function() { main(); } }); function main() { itemsPerPage = 2; // hardcoded data myData1 = [{'xxx':'a1','yyy':'b1','zzz':'c1'}, {'xxx':'a2','yyy':'b2','zzz':'c2'}, {'xxx':'a3','yyy':'b3','zzz':'c3'}, {'xxx':'a4','yyy':'b4','zzz':'c4'}]; // data to be loaded after the ajax call myData2 = []; // define model Ext.define('QueryResultModel', { extend: 'Ext.data.Model', fields: [ {name: 'xxx', type: 'string'}, {name: 'yyy', type: 'string'}, {name: 'zzz', type: 'string'} }); // define store1 myStore1 = Ext.create('Ext.data.Store', { model: 'QueryResultModel', storeId: 'QueryResultStore1', autoLoad: false, pageSize: itemsPerPage, data: myData, // *** use hardcoded data here, and paging works *** proxy : { type: 'pagingmemory' } }); // define store2 myStore2 = Ext.create('Ext.data.Store', { model: 'QueryResultMode', storeId: 'QueryResultStore2', autoLoad: false, pageSize: itemsPerPage, data: {}, // *** empty data here, and once data loaded, paging does not work **** proxy : { type: 'pagingmemory' } }); function createGrid(){ return Ext.create('Ext.grid.Panel', { title: 'Query Result', store: myStore1, // *** hardcoded data columns: [ {text: 'XXX' dataIndex: 'xxx'}, {text: 'YYY' dataIndex: 'yyy'}, {text: 'ZZZ' dataIndex: 'zzz'} ], dockedItem : [{ xtype: 'pagingtoolbar', id: 'pagingBar_id', store : myStore1, // *** use hardcoded data - paging works displayInfo: true, displayMsg: 'Displaying records {0} - {1} of {2}', displayMsg: "No data to display" }] }); }; myContainer = Ext.create('Ext.container.Viewport', { id: 'mainPanel_id', layout: { type: 'border', padding: 5}, renderTo: Ext.getBody(), items: [{ region: 'north', title: 'Whatever Title Here', collapsible: true, autoHeight: true, // *** other congig params here }, { region: 'west', title: 'Query Input', // other config params here buttons : [ { text : 'Submit', id: 'submit_btn', listeners : { click: function(){ sendQuery();} }, { text : 'Reset', // other config parems here } ] }, { region: 'center', xtype: 'tabpanel', autoScroll: true, layout: 'fit', items : [ createGrid()] }, // other config for other regions here ] }); function sendQuery() { // code here to make the ajax call to the server and // retrive the data, if success // load response date into myData2 // note: the grid and pagingtoolbar are pointing to myStore2 (by replacing the myStore1) myStore2.loadData(myData2, false); // after the sendQuery() call, the paging tool bar still shows no data... while the grid is populated with // none of the followings works: // Ext.getCmp('pagingBar_id').doRefresh(); // Ext.getCmp('pagingBar_id').getStore().load(); // myStore2.load({params: {start:0}}); };
};
I am relatively new to extjs. I am facing a problem that I can not resolve. I have been searching online but unable to find the answer. Appreciate any help.
In my code, I am trying to add pagination to the data displayed on the grid. The code makes an ajax call to the server to get the data. The server sends more data than needed. So the client extracts the portion of the response text (json), and displays it in a grid panel.
The grid displays the data fine. But the pagination is not working. It always shows "page 0 of 0" and "No data to display".
But if I substitute the data with hardcoded data, and create the store and grid with the hardcoded data, the pagination works. So it seems like I must already have the data when the store and the grid are being created.
Here's the simplified code. When using myStore1/myData1 (hardcoded data), paging works. Replacing myStore1 and myData1 with myStore2 and myData2, which is loaded after data is retrieved from the server, paging does not work.
All the examples I see online deals with hardcoded data...Appreciate for any insight or pointer.
Ext.Loader.setConfig({ enabled: true }); Ext.Loader.setPath('Ext.ux', 'ext-4.1.1/examples/ux'); Ext.require('Ext.ux.data.PagingMemoryProxy'); Ext.application({ name: 'MS GUI', launch: function() { main(); } }); function main() { itemsPerPage = 2; // hardcoded data myData1 = [{'xxx':'a1','yyy':'b1','zzz':'c1'}, {'xxx':'a2','yyy':'b2','zzz':'c2'}, {'xxx':'a3','yyy':'b3','zzz':'c3'}, {'xxx':'a4','yyy':'b4','zzz':'c4'}]; // data to be loaded after the ajax call myData2 = []; // define model Ext.define('QueryResultModel', { extend: 'Ext.data.Model', fields: [ {name: 'xxx', type: 'string'}, {name: 'yyy', type: 'string'}, {name: 'zzz', type: 'string'} }); // define store1 myStore1 = Ext.create('Ext.data.Store', { model: 'QueryResultModel', storeId: 'QueryResultStore1', autoLoad: false, pageSize: itemsPerPage, data: myData, // *** use hardcoded data here, and paging works *** proxy : { type: 'pagingmemory' } }); // define store2 myStore2 = Ext.create('Ext.data.Store', { model: 'QueryResultMode', storeId: 'QueryResultStore2', autoLoad: false, pageSize: itemsPerPage, data: {}, // *** empty data here, and once data loaded, paging does not work **** proxy : { type: 'pagingmemory' } }); function createGrid(){ return Ext.create('Ext.grid.Panel', { title: 'Query Result', store: myStore1, // *** hardcoded data columns: [ {text: 'XXX' dataIndex: 'xxx'}, {text: 'YYY' dataIndex: 'yyy'}, {text: 'ZZZ' dataIndex: 'zzz'} ], dockedItem : [{ xtype: 'pagingtoolbar', id: 'pagingBar_id', store : myStore1, // *** use hardcoded data - paging works displayInfo: true, displayMsg: 'Displaying records {0} - {1} of {2}', displayMsg: "No data to display" }] }); }; myContainer = Ext.create('Ext.container.Viewport', { id: 'mainPanel_id', layout: { type: 'border', padding: 5}, renderTo: Ext.getBody(), items: [{ region: 'north', title: 'Whatever Title Here', collapsible: true, autoHeight: true, // *** other congig params here }, { region: 'west', title: 'Query Input', // other config params here buttons : [ { text : 'Submit', id: 'submit_btn', listeners : { click: function(){ sendQuery();} }, { text : 'Reset', // other config parems here } ] }, { region: 'center', xtype: 'tabpanel', autoScroll: true, layout: 'fit', items : [ createGrid()] }, // other config for other regions here ] }); function sendQuery() { // code here to make the ajax call to the server and // retrive the data, if success // load response date into myData2 // note: the grid and pagingtoolbar are pointing to myStore2 (by replacing the myStore1) myStore2.loadData(myData2, false); // after the sendQuery() call, the paging tool bar still shows no data... while the grid is populated with // none of the followings works: // Ext.getCmp('pagingBar_id').doRefresh(); // Ext.getCmp('pagingBar_id').getStore().load(); // myStore2.load({params: {start:0}}); };
};
原文:https://stackoverflow.com/questions/25166052
最满意答案
您对容器所做的更改包括:添加诸如电子邮件服务器之类的新软件包,添加vi / nano或其他软件包不会持久化 ,这意味着每次停止并启动容器时 ,所做的更改都将丢失 ,您将不得不重新 - 它。
为了使它们持久化,你必须创建一个Dockerfile,并且在那里你可以指定FROM指令,例如:
FROM "sameersbn/redmine:3.4.2"
在这个Dockerfile中你必须指定你的附加包,例如:
RUN apt-get update && apt-get install xyz
哪个会安装所需的包
然后你必须建立图像:
docker build -t my_new_image:1.0.0 .
这将创建一个新的图像与所需的软件包安装,所以你不会失去它们。
此外,您可以使用COPY或ADD命令或正在使用VOLUMES的方式来添加HTML文件
最后,每次一个好的解决方案使用docker-compose文件时 ,必须始终传递ENV变量,该文件将包含运行容器的所有内容。
希望这可以帮助。
The changes you make to a container such as: adding new packages like a email server, adding vi / nano or other packages would not be persistent which means each time you stop and start the container your changes would be lost and you would have to re-do it.
To make them persistent you would have to create a Dockerfile and in there you can specify the FROM directive such as:
FROM "sameersbn/redmine:3.4.2"
and inside this Dockerfile you would have to specify your additional packages such as:
RUN apt-get update && apt-get install xyz
Which will install the required package(s)
Then you would have to build the images:
docker build -t my_new_image:1.0.0 .
Which will create a new image with the desired packages installed, so you wouldn't lose them.
Also, you could add your HTML files by using the COPY or ADD commands or as you are doing currently using VOLUMES
Lastly, to do have to always pass the ENV variables each time a good solution would be using a docker-compose file which will contain everything to run the container.
Hope this helps.
相关问答
更多-
这是不推荐的,因为你可能会从以前的运行中得到一些意想不到的副作用。 如果您想节省空间,请确保在容器存在之后使用--rm选项清理一旦存在的容器: agent { docker { image ... args '--rm' } } 或者通过运行docker system prune --volumes -f将清理未使用的docker映像和容器和卷。 This is not recommended, as you migh ...
-
我刚刚在子域上设置它。 我想尝试在子目录上代理它,但我的主网站一直在干扰规则。 I just ended up setting it up on a sub-domain. I wanted to try to proxy it on a sub-directory, but my main website kept interfering with the rules.
-
现在,我找到了两个关于如何使用https / SSL / TLS的两个VirtualHost的良好描述。 您需要Apache Version> = 2.2.12 http://www.techrepublic.com/blog/linux-and-open-source/configure-apache-to-support-multiple-ssl-sites-on-a-single-ip-address/ https://wiki.apache.org/httpd/NameBasedSSLVHosts ...
-
我曾经使用过Puphpet安装(它提供了RVM(这似乎是问题。我通过做一个非常备用的Vagrant盒子设置并随后手动安装RVM来修复它。 而对于记录,它所寻找的Version常量是Ruby核心库的一部分,特别是在rexml I had used a Puphpet installation (which provided RVM( and that seemed to be the problem. I fixed it by doing a pretty spare Vagrant box setup a ...
-
任务:TOP => redmine:plugins:migrate => environment(Tasks: TOP => redmine:plugins:migrate => environment)[2023-03-15]
该插件仅与Redmine 2.4,2.5和1.4兼容,如项目网站http://projects.andriylesyuk.com/project/redmine/scm-creator所述 。 您必须使用其他插件或降级Redmine版本。 The plugin is only compatible compatible with Redmine 2.4, 2.5, and 1.4 as is documented on the project's website at http://projects.and ... -
只要配置没有改变, Compose 将始终重用容器 。 如果容器中有任何状态,则需要将该状态放入卷中。 容器应该是短暂的,你应该能够销毁它们并在任何时候重新创建它们而不会丢失任何东西。 如果你需要初始化某些东西,我会在Dockerfile中执行它,以便它保存在图像中。 Compose will always reuse containers as long as their config hasn't changed. If you have any state in a container, you ne ...
-
您对容器所做的更改包括:添加诸如电子邮件服务器之类的新软件包,添加vi / nano或其他软件包不会持久化 ,这意味着每次停止并启动容器时 ,所做的更改都将丢失 ,您将不得不重新 - 它。 为了使它们持久化,你必须创建一个Dockerfile,并且在那里你可以指定FROM指令,例如: FROM "sameersbn/redmine:3.4.2" 在这个Dockerfile中你必须指定你的附加包,例如: RUN apt-get update && apt-get install xyz 哪个会安装所需的包 ...
-
如何在使用Docker时启用Redmines的“添加问题”?(How to enable Redmines 'adding of issues' when using Docker?)[2023-06-10]
Redmine没有底层基础结构的概念,因此如果未显示“新问题”按钮,则与文件系统或数据库级别的缺少写入权限无关。 如果您可以登录,那么您的Redmine已经成功执行了数据库UPDATE ,并且创建问题不需要任何其他内容,因此在检查Docker配置时您将查找错误的位置。 我几乎可以肯定你缺少权限或默认配置(例如问题状态,问题优先级,角色,跟踪器,工作流程等),如上面的评论所述。 我假设您的Redmine数据库中还没有任何相关数据。 如果是这种情况,请尝试以下方法。 警告:这将删除所有Redmine数据。 ex ... -
已经解决了。 我使用了这些ffg命令: bundle exec rake generate_secret_token set RAILS_ENV=production bundle exec rake db:migrate Already resolved. I used these ffg commands: bundle exec rake generate_secret_token set RAILS_ENV=production bundle exec rake db:migrate
-
使用Thin运行的Rails应用程序(Redmine)中的权限被拒绝(Permission denied in Rails app (Redmine) running with Thin)[2023-10-14]
对于unlink文件权限进程实际上需要一个权限来写入该文件的目录。 因此要么给予redmine写入/var/run/thin/权限,要么将pids和socket放在别处 - 通常在app的共享tmp ,rails甚至为这些创建目录。 For unlink file permission process actually need a permission to write the directory of that file. So either give redmine permission to wri ...