Index: fittingview/src/sans/perspectives/fitting/fitproblem.py
===================================================================
--- fittingview/src/sans/perspectives/fitting/fitproblem.py	(revision 3fb5e68855abdab827c0d6d45dee1deec6198aa3)
+++ fittingview/src/sans/perspectives/fitting/fitproblem.py	(revision f64a4b748c9e918384f698fff478f9a69e67d520)
@@ -157,4 +157,8 @@
         self.scheduled = 0
         self.fit_tab_caption = ''
+        self.nbr_residuals_computed = 0
+        self.batch_inputs = {}
+        self.batch_outputs = {}
+       
  
     def enable_smearing(self, flag=False, fid=None):
@@ -415,9 +419,10 @@
         return self.itervalues()
     
-    def set_result(self, result):
+    def set_result(self, batch_inputs, batch_outputs):
         """
         set a list of result
         """
-        self.result = result
+        self.batch_inputs = batch_inputs
+        self.batch_outputs = batch_outputs
                 
     def get_result(self):
@@ -425,5 +430,5 @@
         get result 
         """
-        return self.result
+        return self.batch_inputs, self.batch_outputs
     
     def set_graph_id(self, id):
Index: fittingview/src/sans/perspectives/fitting/fitting.py
===================================================================
--- fittingview/src/sans/perspectives/fitting/fitting.py	(revision 342dc442b417cd5d6e50247eb896f1abbdba0f73)
+++ fittingview/src/sans/perspectives/fitting/fitting.py	(revision f64a4b748c9e918384f698fff478f9a69e67d520)
@@ -46,4 +46,5 @@
 
 (PageInfoEvent, EVT_PAGE_INFO)   = wx.lib.newevent.NewEvent()
+(BatchDrawEvent, EVT_BATCH_DRAW)   = wx.lib.newevent.NewEvent()
 
 if sys.platform.count("darwin")==0:
@@ -268,4 +269,5 @@
         self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event)
         self.parent.Bind(EVT_SLICER_PARS_UPDATE, self._onEVT_SLICER_PANEL)
+        self.parent.Bind(EVT_BATCH_DRAW, self.on_display_grid)
         self.parent._mgr.Bind(wx.aui.EVT_AUI_PANE_CLOSE,self._onclearslicer)    
         #Create reader when fitting panel are created
@@ -639,4 +641,5 @@
                    enable1D=True, enable2D=False,
                    state=None,
+                   fid=None,
                    toggle_mode_on=False,
                    qmin=None, qmax=None, 
@@ -667,4 +670,5 @@
                                qmin=qmin,
                                qmax=qmax, 
+                               fid=fid,
                                weight=weight,
                                toggle_mode_on=toggle_mode_on,
@@ -680,4 +684,5 @@
                                 qmin=qmin,
                                 qmax=qmax,
+                                fid=fid,
                                 weight=weight,
                                 state=state,
@@ -725,4 +730,5 @@
             try:
                 if value.get_scheduled() == 1:
+                    value.nbr_residuals_computed = 0
                     #Get list of parameters name to fit
                     pars = []
@@ -1054,6 +1060,7 @@
                         batch_inputs["error on %s" % pars[index]].append(item)
             pid = page_id[0]
-            self.page_finder[pid].set_result(result=batch_outputs)   
-           
+            self.page_finder[pid].set_result(batch_inputs=batch_inputs,
+                                             batch_outputs=batch_outputs)   
+            count = len(self.page_finder[pid].keys())
             for pid in page_id:
                 cpage = self.fit_panel.get_page_by_id(pid)
@@ -1074,57 +1081,49 @@
                                       state=None,
                                       toggle_mode_on=False,
+                                      fid=fid,
                                       qmin=qmin, qmax=qmax, 
                                       update_chisqr=False, 
                                       weight=weight)
-        #get theory data and residuals of each data then send all values
-        # to the grid  
-        wx.CallAfter(self.on_set_batch_result, page_id, pars, batch_outputs, 
-                batch_inputs)
+           
+    
+        
                     
-    def on_set_batch_result(self, page_id, pars, batch_outputs, batch_inputs):
-        """
-        """
-        for pid in page_id:
-            fitproblem_list = self.page_finder[pid].values()
-            fitproblem_list.sort()
-            index = 0
-            for fitproblem in fitproblem_list:
-                residuals =  fitproblem.get_residuals()
-                theory_data = fitproblem.get_theory_data()
-                data = fitproblem.get_fit_data()
-                model = fitproblem.get_model()
-                 #fill batch result information
-                if "Data" not in batch_outputs.keys():
-                    batch_outputs["Data"] = []
-                from sans.guiframe.data_processor import BatchCell
-                cell = BatchCell()
-                cell.label = data.name
-                cell.value = index
-                cell.object = [data, theory_data]
-                
-                for param in model.getParamList():
-                    if param not in pars:
-                        if param not in batch_inputs.keys():
-                            batch_inputs[param] = []
-                        if param not in model.non_fittable:
-                            batch_inputs[param].append(model.getParam(param))
-                batch_outputs["Data"].append(cell)
-                for key, value in data.meta_data.iteritems():
-                    if key not in batch_inputs.keys():
-                        batch_inputs[key] = []
-                    batch_inputs[key].append(value)
-                param = "temperature"
-                if hasattr(data.sample, param):
-                    if param not in  batch_inputs.keys():
-                         batch_inputs[param] = []
-                    batch_inputs[param].append(data.sample.temperature)
-                # associate residuals plot
-                batch_outputs["Chi2"][index].object = residuals
-          
-        self.parent.on_set_batch_result(data_outputs=batch_outputs, 
-                                            data_inputs=batch_inputs,
-                                            plugin_name=self.sub_menu)
-             
-             
+    def on_set_batch_result(self, page_id, fid, batch_outputs, batch_inputs):
+        """
+        """
+        
+        pid =  page_id
+        if fid not in self.page_finder[pid]:
+            return
+        fitproblem = self.page_finder[pid][fid]
+        index = self.page_finder[pid].nbr_residuals_computed - 1
+        print "index", index
+        residuals =  fitproblem.get_residuals()
+        theory_data = fitproblem.get_theory_data()
+        data = fitproblem.get_fit_data()
+        model = fitproblem.get_model()
+        #fill batch result information
+        if "Data" not in batch_outputs.keys():
+            batch_outputs["Data"] = []
+        from sans.guiframe.data_processor import BatchCell
+        cell = BatchCell()
+        cell.label = data.name
+        cell.value = index
+        theory_data.id = wx.NewId()
+        cell.object = [data, theory_data]
+        
+        batch_outputs["Data"].append(cell)
+        for key, value in data.meta_data.iteritems():
+            if key not in batch_inputs.keys():
+                batch_inputs[key] = []
+            batch_inputs[key].append(value)
+        param = "temperature"
+        if hasattr(data.sample, param):
+            if param not in  batch_inputs.keys():
+                 batch_inputs[param] = []
+            batch_inputs[param].append(data.sample.temperature)
+        # associate residuals plot
+        batch_outputs["Chi2"][index].object = [residuals]
+       
     def _single_fit_completed(self, result, pars, page_id, batch_outputs,
                           batch_inputs=None,  elapsed=None):
@@ -1396,5 +1395,5 @@
         
     def _complete1D(self, x, y, page_id, elapsed, index, model,
-                    weight=None,
+                    weight=None, fid=None,
                     toggle_mode_on=False, state=None, 
                     data=None, update_chisqr=True):
@@ -1444,9 +1443,10 @@
                                  Chi2UpdateEvent(output=self._cal_chisqr(
                                                                 data=data,
+                                                                fid=fid,
                                                                 weight=weight,
                                                             page_id=page_id,
                                                             index=index)))
                 else:
-                    self._plot_residuals(page_id=page_id, data=data,
+                    self._plot_residuals(page_id=page_id, data=data, fid=fid,
                                           index=index, weight=weight)
 
@@ -1468,6 +1468,5 @@
   
     def _complete2D(self, image, data, model, page_id,  elapsed, index, qmin,
-                    
-                     qmax, weight=None, toggle_mode_on=False, state=None, 
+                qmax, fid=None, weight=None, toggle_mode_on=False, state=None, 
                      update_chisqr=True):
         """
@@ -1520,8 +1519,9 @@
                              Chi2UpdateEvent(output=self._cal_chisqr(data=data,
                                                                     weight=weight,
+                                                                    fid=fid,
                                                          page_id=page_id,
                                                          index=index)))
             else:
-                self._plot_residuals(page_id=page_id, data=data,
+                self._plot_residuals(page_id=page_id, data=data, fid=fid,
                                       index=index, weight=weight)
         msg = "Computation  completed!"
@@ -1533,4 +1533,5 @@
                       description=None, enable2D=False,
                       state=None,
+                      fid=None,
                       weight=None,
                       toggle_mode_on=False,
@@ -1561,4 +1562,5 @@
                                     qmax=qmax,
                                     weight=weight, 
+                                    fid=fid,
                                     toggle_mode_on=toggle_mode_on,
                                     state=state,
@@ -1577,4 +1579,5 @@
                 state=None,
                 weight=None,
+                fid=None, 
                 toggle_mode_on=False, update_chisqr=True, 
                 enable1D=True):
@@ -1601,4 +1604,5 @@
                                   state=state,
                                   weight=weight,
+                                  fid=fid,
                                   toggle_mode_on=toggle_mode_on,
                                   completefn=self._complete1D,
@@ -1613,5 +1617,5 @@
   
     
-    def _cal_chisqr(self, page_id, data, weight, index=None): 
+    def _cal_chisqr(self, page_id, data, weight, fid=None, index=None): 
         """
         Get handy Chisqr using the output from draw1D and 2D, 
@@ -1667,9 +1671,11 @@
         chisqr = numpy.average(residuals * residuals)
         self._plot_residuals(page_id=page_id, data=data_copy, 
+                             fid=fid,
                              weight=weight, index=index)
         
         return chisqr
     
-    def _plot_residuals(self, page_id, weight, data=None, index=None): 
+    def _plot_residuals(self, page_id, weight, fid=None,
+                        data=None, index=None): 
         """
         Plot the residuals
@@ -1753,8 +1759,55 @@
         title = new_plot.name 
         self.page_finder[page_id].set_residuals(residuals=new_plot, fid=data.id)
+        batch_on = self.fit_panel.get_page_by_id(page_id).batch_on
+        
+        # Need all residuals before plotting
+        # Should be refactored
+        n = len(self.page_finder[page_id].keys())
+        m = self.page_finder[page_id].nbr_residuals_computed
+        flag = False
+        batch_inputs, batch_outputs = self.page_finder[page_id].get_result()
+      
+        if self.page_finder[page_id].nbr_residuals_computed == -1:
+            flag = False
+        else:
+            if m == n - 1:
+                flag = True
+            else:
+                flag = False
+                self.page_finder[page_id].nbr_residuals_computed += 1
+            
+            self.on_set_batch_result(page_id=page_id,
+                                 fid=fid,
+                              batch_outputs=batch_outputs, 
+                                batch_inputs=batch_inputs) 
         # plot data
-        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 
+        event = BatchDrawEvent(page_id=page_id , 
+                           batch_on=batch_on,
+                           batch_outputs=batch_outputs,
+                           batch_inputs=batch_inputs,
+                           is_displayed=flag)
+        wx.PostEvent(self.parent, event)
+        
+        if not batch_on:
+            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title))
+            
         #reset weight  
         #self.weight = None
+        
+    def on_display_grid(self, event):
+        """
+        deplay batch result
+        """
+        page_id = event.page_id
+        batch_on = event.batch_on
+        flag = event.is_displayed
+        batch_outputs = event.batch_outputs
+        batch_inputs = event.batch_inputs
+        if flag and batch_on:
+            self.parent.on_set_batch_result(data_outputs=batch_outputs, 
+                                            data_inputs=batch_inputs,
+                                            plugin_name=self.sub_menu)
+            self.page_finder[page_id].nbr_residuals_computed = -1
+       
 #def profile(fn, *args, **kw):
 #    import cProfile, pstats, os
Index: fittingview/src/sans/perspectives/fitting/model_thread.py
===================================================================
--- fittingview/src/sans/perspectives/fitting/model_thread.py	(revision 62f851fb7213a06069ca007c15e29566808e052c)
+++ fittingview/src/sans/perspectives/fitting/model_thread.py	(revision f64a4b748c9e918384f698fff478f9a69e67d520)
@@ -18,4 +18,5 @@
                  state=None,
                  weight=None,
+                 fid=None,
                  toggle_mode_on=False,
                  completefn=None,
@@ -32,4 +33,5 @@
         self.qmax = qmax
         self.weight = weight
+        self.fid = fid
         #self.qstep = qstep
         self.toggle_mode_on = toggle_mode_on
@@ -104,4 +106,5 @@
                        elapsed=elapsed,
                        index=index_model,
+                       fid=self.fid,
                        qmin=self.qmin,
                        qmax=self.qmax,
@@ -118,4 +121,5 @@
                  page_id,
                  data,
+                 fid=None,
                  qmin=None,
                  qmax=None,
@@ -136,4 +140,5 @@
                  yieldtime,
                  worktime)
+        self.fid = fid
         self.data = data
         self.qmin = qmin
@@ -172,4 +177,5 @@
                       state=self.state,
                       weight=self.weight,
+                      fid=self.fid,
                       toggle_mode_on=self.toggle_mode_on,
                       elapsed=elapsed,index=index, model=self.model,
