Extjs grid relies on external store, not rendering properly - extjs

I have an Extjs (version 6, classic API) panel with a grid in it. This grid has its own store that is ready to go within initComponent(). It's iterating over those records just fine. The issue is that one column has a custom renderer that relies on another store. This store may or may not be loaded depending on a few different factors. As a result, the grid doesn't render that column correctly. I find myself in a bit of a pickle as to how to deal with that. The basic concept is that the value for that column is just a key that means nothing to the user. This key is looked up in the non-grid store to display the data correctly using the renderer attribute in the grid column. All of the code is executing fine, but it's the issue of having that store loaded, and when it does load, it does not trigger a rerender of that column as it's not the store for the grid itself.
I could load the store synchronously before initComponent() is complete, but that's hardly ideal. I can't tell it to wait for the store to load during the render phase as that will leave the column blank if the store isn't loaded. I need to trigger a rerender of that column somehow or get it to properly wait if the non-grid store isn't loaded. Any ideas?

AFAIK there is no way to tell a grid to rerender a certain column. So you will have to refresh the whole grid:
myGrid.on('afterrender',function(grid) {
externalStore.on('load',function() {
grid.getView().refresh();
});
});

Related

How to refresh ag-grid frequently with React?

I have an ag-grid instance, which have to be updated continuously, every few seconds, with fresh data by calling a service.
I want the grid to update only the cells with changed data.
Is there any way to achieve this using React?
Thanks in advance.
assuming you bind the grid data correctly, and don't alter the rowBuffer, or otherwise force the grid to render all its data to the DOM (thereby turning off virtualization), you should be fine.
the grid will test for changes in the data and only render what was updated (see the docs on change-detection).
if you still find you need some boost (like when you have real large datasets) you can try batch-transactions.
all of the above is correct regardless of framework; these are core features of ag-grid.

ExtJS Grid roweditor still dirty after grid save and store reload

I'm using ExtJS 5.1.3, I have a grid which is loaded from a store which has a model. The grid is set to use plugin roweditor, so I edit a cell and give it a new value, at this point the red tick is shown that the cell has been changed.
I have a Save button which when clicked gets the store.getModifiedRecords() and passes these off to a ajax request, upon success of this request a few things happen and the last action I do is to load the grid store again which then populates the grid again with the latest version of the data, this is fine and seems to be working as expected.
As this is a multi page application I also have a check when a user navigates away from this page, this is to catch any unsaved grid changes, so basically I get any form from the page and verify the isDirty() value, this is where I am finding my issue, the roweditor is being returned as dirty, this is because some columns have an editor and ExtJS uses form validation on these fields,
I can't understand why the store loading again has not cleared any dirty fields associated with the grid columns? I've tried a number of things such as clearing the store prior to ajax request along with refreshing the grid view, I've tried committing the store changes prior to doing the ajax request but each time I try navigate away from the page after a grid save I pick up the roweditor as having dirty fields :( any help is greatly appreciated.
EDIT: managed to replicate on a simple fiddle
https://fiddle.sencha.com/#view/editor&fiddle/1rmf
The fiddle is basic, to replicate follow these steps;
edit first row age, change age to 13
click Save (i'm forcing the store to load data which has the change we've made)
click 'Check roweditor is Dirty() value' button to see the value of the roweditor isDirty() function, this will return true
if you look at the button handler, you can drill into forms[0].items.items[2] and see that this field has dirty: true which is why isDirty() is returning true.
SOLUTION
As explained in accepted answer, the roweditor is not affected by the store edit/cancel or load in my case. What I did when clicking on 'Save' was to get the grid, then the editor and it's form and called reset() on this so effectively sync everything again.
grid.editingPlugin.getEditor().form.reset();
you can also get access to plugins via grid.getPlugins() which returns an arrary
updated fiddle to show it working
https://fiddle.sencha.com/#view/editor&fiddle/1rmr
During the editing process grid will eventually call loadRecord on the editor's form. However the editor's form is not cleared upon editing success or canceling. That is why your check for dirtyness returns false.
Grid reloading the data is not destroying the editors. It is an optimisation. Editors are created only once and they are destroyed along with the grid.
I'll try to answer regarding to an experience of mine with an all ExtJS desktop application.
By the way looking quickly over your description, you may have to call the Store.sync() method that refreshes your store.
Looking more deeply, there are many way to make CRUD using ExtJs.
I've been made using the "instance" of store but at certain point I had to change it to static calls like MyApp.store.Model.save() etc. That makes you have only one instance of the store avoiding dirty data.
Here's my project folder if you need
https://github.com/guilhermeribeirodev/grizzlyboilerplate/tree/master/src/main/webapp/js/MyApp

extjs 3 store load new records while keeping previous

I'm using a store to load data into a dataview tpl. The desired behavior is when user scrolls down to bottom, new records are loaded while previous remain there.
I've Already Tried This:
How to load additional records into the store/keep previous while loading new ones
But the above mentioned solution is not working for me as i'm trying to use it in ExtJS 3.
Is there any solution for ExtJS 3.4?
NB: I'm loading store every time user scrolls down to bottom by store.load();
check store.load method's add param,
which is Indicator to append loaded records rather than replace the current cache.
e.g.store.load({add:true})
refer docs

ExtJS4 gridPanel data not showing

I've made this very simple jsfiddle to show you this abnormal behaviour http://jsfiddle.net/mrgamer/GgUkE/2/
In my application i'm using the same methods i've written here, .loadRawData() on the store, cause .loadData() doesn't fire the 'load' event.
I'm filling the store manually cause i've to filter some JSON data, compile it, and then insert to this store.
Anyway the problem doesn't seem to be in the store, since the Grid gets populated, you can click on 2 rows, but the data isn't displayed!
Updated
There was a typo in the dataIndex properties in your columns. Required a capital 'I'
Grid Panel with Store example
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.Panel
Fixed code
http://jsfiddle.net/fw3Vc/1/

Extjs grid column render function, access to external store

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.
What are the possible solutions to this problem?
Thank you very much in advance,
David
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()
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.

Resources