ExtJS 4.0: Keeping a row at the top position in a GridPanel

I’ve had the need for a grid I am working on keep a row representing the user currently logged in as the top row in the grid. Mind you there is no paging on this grid. I am using a slightly outdated version of ExtJS, i.e 4.0. I tried listening to the viewready event on the grid itself or its view but those events were not firing. Seems the viewready event is only available on the view as of ExtJS 4.1. To alleviate this problem the next best thing available to me was the refresh event, which event though would be called many times over did the job of informing me of when the view rows are actually displayed, which the afterrender event does not provide.

I ended adding the following listener to my grid’s viewConfig definition:


and the moveUserRowToTop function does this:

moveUserRowToTop:function(gridView, eOpts)
var store = gridView.getStore();
var currentUserRecordIndex = store.find('id',currentUser.get('id'))
if(currentUserRecordIndex > 0)
    var currentUserRecord = store.getAt(currentUserRecordIndex);
    store.insert(0, [currentUserRecord]);



So as you can see even though the event gets fired a lot depending on your grid usage, mine is average it will only move the row if it is present and at an index greater than 0, which is exactly my use case.

Hope it helps


African Tech Tidbits: Week of February 13th 2012

X-Net The first Cameroonian created cell phone
X-Net The first Cameroonian created cell phone

It’s the middle of the week, I’ve been busy with life and wanted to post a few articles but never got time, so  decided to start a new, hopefully weekly series of articles aggregating articles that I find interesting related to Africa and Tech. So for this week:

Over at Forbes, a list of the top 20 African Tech startups: A good variety in terms of business models and technologies, going from social networks, job portals and mobile shops/apps to payment solutions, but the overall trend is definitely in the mobile space.

The lucrative skills African talent should acquire in 2012: An interesting article at Appfrica on what skills techies and non techies should acquire in the ongoing year. From a developer perspective I found it pretty much accurate and in line with the trends I am seeing in the US especially with the re-emergence of RoR and Python/Django as viable alternative. Food for beyond thought, action. There is also a set of skills for non techies that are good to possess.

Internet Outages in Benin(in French): The Internet is out again in Benin with no warning, back in January the whole country went off the grid for a whole week because of a fire at one of the routing hubs, and the problem seem to be back. My friend Senam at Etrilabs has been living this from the front lines and this is a highlight of one of the biggest issues with trying to do tech business in certain African countries, which is one, the lack of supporting infrastructure and two, outdated or counter-productive government regulations. Can you imagine trying to run a tech hub with no internet access for a week? And when we’re talking about Internet, we’re not talking about your run of the mill cable connection that they’d be happy to have, we’re talking about the low rungs of the scale ADSL connections. The other alternative is satellite internet connections, but this too is heavily regulated (as pay us a very hefty, does not make business sense,  license fee) by the Beninese government which even has a sniffer truck driving around looking for illegal SAT setup to impose heavy fines.

Meet X-Net, the first African designed cell phone: Created by a three Cameroonian expatriates in the US and Germany (manufactured in China), this cell phone features two SIM card slots, an MP3/MP4 player, an optional camera, FM radio and a flashlight. It’s already being sold in Cameroon by Lekoua & Fils for about $21 to $25 depending on the camera option. The engineers behind this basic phone worked on it for a year and wished to remain anonymous as they are currently working for western cell phone makers.