PDA

View Full Version : How to invoke RowNumberer column renderer without using gridview refresh?



mx_starter
22 Nov 2013, 8:52 AM
Hello - as we know into the grid


grid.getView().refresh()

causes the columns which have renderer functions defined (including 'rownumberer') to redraw their content.

I need to refresh my 'rownumberer' column without using the refresh() method of the view (for other reasons).

So - is that possible and how to accomplish it?

mx_starter
22 Nov 2013, 9:08 AM
So may be the right question is - what exactly the view is doing to force the renderer function of the column to be executed?

mitchellsimoens
3 Dec 2013, 1:14 PM
First question I have is why do you need the rownumberer column to rerender? Normally this should be handled for you.

mx_starter
4 Dec 2013, 12:26 AM
First question I have is why do you need the rownumberer column to rerender? Normally this should be handled for you.

Well, it is complicated, but i will try to explain:

1. I have a grid which is with limited height and the store is not paged.
2. The grid can contain many rows and of course not all of them are visible at once on the screen. This is why the grid uses autoscroll: true.
3. The grid has an action column which allows for the records to be added and reordered by the user.
4. Each time the user adds new record - it MUST appear at the bottom of the grid.

All this is working as expected up to now.
The problem is that the rownumberer column must be updated automatically so that if a user moves record 30 above record 29, the values of the rownumberer column for record 30 should become 29 and for the record 29 - should become 30. The aim is rownumberer column to be always sorted from lower to higher values. Hope it is clear?

Well - the renumbering is accomplished using the refresh method of the grid's view and that is working as expected (but you must use Ext v. 4.2.2 as older versions will perform incorrect!!!).

But unfortunately when you call refresh() on the view, it also makes so that the current scroll position of the grid is lost and you will see the "top part" of the view. Can you understand what i mean? My English is not very well...

This becomes even more irritating if you are viewing the bottom of the grid and adding a new record which you then start to edit automatically using celleditor/roweditor plugin. So you click the "add" icon from the action column on the last row, the new row is added and the editor appears in place so you can immediately start to edit it. This is OK - but you do not have rownumberer column with the next value UNTIL you call refresh() on the view.

On the other hand - refresh() adds the correct row number, but also automatically scrolls the view ot its top so you finish with an activated editor on a cell that is not visible for the user and he must scroll to the bottom side again.

I will try to post a fiddle to illustrate this.

mx_starter
4 Dec 2013, 1:46 AM
Well Mitchel, here is the sample fiddle i mentioned above:

It must be pointed out that Sencha Fiddle is not allowing Ext 4.2.2 to be used - that is why the rownumberer column is defined as xtype: 'rownumberer422' component - it sumply contains the renderer function copied from the 4.2.2 SDK.


1u6

mx_starter
12 Dec 2013, 4:30 AM
any suggestions here?