PDA

View Full Version : How to refresh a grid view without reloading the bound store?



fenderico
29 Aug 2013, 5:26 AM
Hi everybody,

I have a grid panel with its store. I modify a couple of records using set(), and right after that the those records are marked as dirty. What I want to do is to sort the records displayed in the grid without reloading the store. I want to sort them taking into account the last records changes.

So, this is what I do:



record1.set('priority', 1);
record2.set('priority', 2);


After that, I'd like the grid shows the changes. The store is sorted by priority field.
Does anybody can give me a hint to do that?

Thanks in advance,

Farish
29 Aug 2013, 5:39 AM
the store offers a sort method. take a look at its documentation (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-method-sort) but if you have remoteSort set to true, then it will send a request to the backend when you call sort function.

to just refresh the view, you can use:

grid.getView().refresh();

fenderico
29 Aug 2013, 5:56 AM
Hi Farish,

I'd already tried sort(), having remoteSort set to false, but it didn't refresh the grid view.

Regarding to getting a grid view reference and executing refresh(), I've also tried that, but it doesn't refresh the grid. The grid shows off the rows as dirty but they keep in the same place and order.

I don't know what else I can try.

Thanks for your response.

Farish
29 Aug 2013, 6:04 AM
can you put a working example on jsfiddle.net with static data loaded from an array into the store? that might help others figure out the problem.

scottmartin
29 Aug 2013, 6:35 AM
Please note that we also have our new Sencha Fiddle available as well ;)
https://fiddle.sencha.com/#home

Scott.

scottmartin
29 Aug 2013, 6:50 AM
Please make adjustments to this to duplicate your problem:
https://fiddle.sencha.com/#fiddle/d2

fenderico
29 Aug 2013, 8:38 AM
Thanks to both of you. I'll try to replicate my problem in sencha fiddle, which by the way looks awesome.

fenderico
29 Aug 2013, 9:22 AM
Thank you very much Scott! I found my problem. I was using store.sort() without passing any parameter and I hadn't set to the store any sort param as default.

So this line
store.sort('priority', 'ASC') fixed my problem.