Showing posts with label event. Show all posts
Showing posts with label event. Show all posts

Monday, August 19, 2013

DGrid data refreshing event?

I'm working on dojo chart generation based on the data from dojo dgrid. 
The logic I'm building is as follows: 
1. Subscribe to a topic in the main page: 
connect.subscribe("dgridrefresh", mModule.generateRestChart); 
2. Initiate a JsonRest datastore. Use the datastore to create a dgrid with pagination plugin. 
3. Start the dgrid in some contentpane. 
4. Publish an event to a topic upon "dgrid-refresh-complete" event. 
The code is as follows (topicname is the paramter): 
dgrid.on("dgrid-refresh-complete", function(event) { 
                                console.log("refresh-complete. Publishing to " + topicname); 
                                require(["dojo/_base/connect"], function(connect) { 
                                        connect.publish(topicname, [event]); 
                                }); 
                        }); 

However, I observed that mModule.generateRestChart() function was only invoked once when the dgrid was initiated. I expect the method being called whenever pagination is executed. 

Same information is here:http://dojo-toolkit.33424.n3.nabble.com/get-data-refresh-notification-from-dgrid-with-jsonrest-datastore-td3998670.html

In the end, it turned out the dgrid-refresh-complete event will only be emitted once when dgrid is refreshed with loading the first page of data.
I did a workaround by customizing the pagination plugin for dgrid. The change I made was pretty simple: inside the Deferred block of gotoPage method of dgrid.extensions.Pagination, I added another emit of dgrid-navigation-complete event, which is a customized event by myself.