Función de representación de la columna de cuadrícula Extjs, acceso a la tienda externa

I have 2 stores and 1 gridpanel. One store is assigned to the grid, the other is loaded with records at the beginning of my application.

Now, my problem is that when I use a render function for a column in my gridpanel, I would like to access the records of the otrher store. However, the other store is not always ready and not always full of records at the rendering moment.

¿Cuáles son las posibles soluciones a este problema?

Thank you very much in advance, David

preguntado el 03 de mayo de 12 a las 12:05

2 Respuestas

Load this second store before rendering the grid. What's seems to be a problem?

Update: you need to make sure that store2 is loaded before store1. You can do this like this:

  • Don't bind store1 to your grid first in the view definition. Assign all columns and other stuff, but leave store being null
  • In the controller on afterrender event you assign handler to the store2 load event in which you call store1.load()
  • Do store2.load()

contestado el 03 de mayo de 12 a las 12:05

Thanks for your reply. but where should I load it? I tried to load in the initComponent method of the view, just before the grid creation, but the problem arises. - toque del destino

Idea is - you need to make sure store2 is loaded before store1. Because once store1 is loaded your grid will render all records. I will update my answer. - sha

And I would appreciate if you mark my other answer to one of your questions as answered :) - sha

Thanks for the reply. My problem now, is that in the init function of my controller: init: function(){ ... var mainView = Ext.create('DKM.Views.Administration.User.List'); mainView.on (afterrender, function(){ console.log("rendered"); },this); } It's like the event is not fired... - toque del destino

put a quotes around 'afterrender'... why did you mark other answer as answered? It has nothing to do with your question? - sha

I understand one store is dependent of the other? if so load the second store on the selection of an item from the first. Or, you can just create a method to look in the data that you use to fill the store and find the thing you need.

contestado el 03 de mayo de 12 a las 12:05

I have two models: a user model and a hotel model. A user can have many hotels and a hotel can have many user assigned. Now, my grid lists the users and, in the column "hotels" I would like, for every user, a comma separated list of the hotels the user is assigned to. And here the problem arises. When I render the column "hotels" the store "hotels" sometimes (sometimes, which is clearly a timing problem) is not ready and not loaded with data. - toque del destino

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.