首页 \ 问答 \ extjs 4.1.1 - 本地数据的网格分页(extjs 4.1.1 - Pagination in grid on local data)

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
更新时间:2023-08-26 16:08

最满意答案

您对容器所做的更改包括:添加诸如电子邮件服务器之类的新软件包,添加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 .

这将创建一个新的图像与所需的软件包安装,所以你不会失去它们。

此外,您可以使用COPYADD命令或正在使用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 ...
  • 该插件仅与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 哪个会安装所需的包 ...
  • 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
  • 对于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 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)