66import java .util .Enumeration ;
77import java .util .Hashtable ;
88import java .util .Stack ;
9+ import java .util .Collections ;
10+ import java .util .Arrays ;
911
1012import com .genexus .IGXAssigned ;
1113import com .genexus .diagnostics .core .ILogger ;
@@ -28,7 +30,8 @@ public abstract class HttpAjaxContext
2830 protected JSONObject Messages = new JSONObject ();
2931 private JSONObject WebComponents = new JSONObject ();
3032 private Hashtable <Integer , JSONObject > LoadCommands = new Hashtable <>();
31- private JSONArray Grids = new JSONArray ();
33+ private ArrayList Grids = new ArrayList ();
34+ private Hashtable <String , Integer > DicGrids = new Hashtable <String , Integer >();
3235 private JSONObject ComponentObjects = new JSONObject ();
3336 protected GXAjaxCommandCollection commands = new GXAjaxCommandCollection ();
3437 protected GXWebRow _currentGridRow = null ;
@@ -485,13 +488,23 @@ public void ajax_rsp_assign_hidden_sdt( String SdtName, Object SdtObj)
485488 }
486489 }
487490
488- public void ajax_rsp_assign_grid (String gridName , com .genexus .webpanels .GXWebGrid gridObj )
491+ public void ajax_rsp_assign_grid (String gridName , com .genexus .webpanels .GXWebGrid gridObj )
492+ {
493+ Object jsonObj = ((IGxJSONAble ) gridObj ).GetJSONObject ();
494+ Grids .add (jsonObj );
495+ }
496+
497+ public void ajax_rsp_assign_grid (String gridName , com .genexus .webpanels .GXWebGrid gridObj , String Control )
489498 {
490- try {
491- Grids .putIndex (0 , gridObj .GetJSONObject ());
492- }
493- catch (JSONException e ) {
494- }
499+ Object jsonObj = ((IGxJSONAble ) gridObj ).GetJSONObject ();
500+ if (DicGrids .containsKey (Control )) {
501+ Grids .set (DicGrids .get (Control ), jsonObj );
502+ }
503+ else
504+ {
505+ Grids .add (jsonObj );
506+ DicGrids .put (Control , Grids .size () - 1 );
507+ }
495508 }
496509
497510 public void ajax_rsp_clear (){
@@ -586,6 +599,8 @@ protected String getJSONResponsePrivate(String cmpContext)
586599 GXJSONObject jsonCmdWrapper = new GXJSONObject (isMultipartContent ());
587600 try
588601 {
602+ Collections .reverse (Arrays .asList (Grids ));
603+ JSONArray JSONGrids = new JSONArray (Grids );
589604 if (commands .AllowUIRefresh ())
590605 {
591606 if (cmpContext == null || cmpContext .equals ("" ))
@@ -598,7 +613,7 @@ protected String getJSONResponsePrivate(String cmpContext)
598613 jsonCmdWrapper .put ("gxValues" , AttValues );
599614 jsonCmdWrapper .put ("gxMessages" , Messages );
600615 jsonCmdWrapper .put ("gxComponents" , WebComponents );
601- jsonCmdWrapper .put ("gxGrids" , Grids );
616+ jsonCmdWrapper .put ("gxGrids" , JSONGrids );
602617 }
603618 for (Enumeration loadCmds = LoadCommands .keys (); loadCmds .hasMoreElements ();)
604619 {
0 commit comments