title: in EXTJS how to load data in a Grid on selecting a row in another grid with OnSelectRow?
body: <p>I am new to extjs. and I developing a application in which two grids are there. on clicking the row of first grid, second grid should display data according to selected particular row. I dont know how to pass value of that row to servlet page??</p>
  
  <p>below is the code for first grid...</p>
  
  <pre><code>     var store = new Ext.data.JsonStore({
      fields: [
      'YCSET_ID','YCSET_DESC', 'YCSET_CCY', 'YCSET_COMP_MODE','YCSET_YCTYPE','YCSET_INTBASIS','YCSET_DISC_FACTOR'
              ],
      proxy: {
          type: 'ajax',
          url: 'USCities',
          params: {
              store_id: 1
  
      },
      scope:this,
      //method to call when the request is successful
      success: this.onSaveSuccess,
      //method to call when the request is a failure
      failure: this.onSaveFailure,
          reader: {
                 type: 'json',
                 root: 'cityList'
             }
      }
          });
       store.load();
         // create the Grid
          var grid = new Ext.grid.GridPanel({
              selType: 'cellmodel',
              trackMouseOver: true,
              plugins: [
                  Ext.create('Ext.grid.plugin.CellEditing', {
                      clicksToEdit: 2
                  })
                  ],
         store: store,
          columns: [
                  {xtype: 'rownumberer'},
                  {header: 'YCSET_ID', width: 90, id :'ycset_id',sortable: true, dataIndex: 'YCSET_ID',editor: 'textfield'},
                  {header: 'YCSET_DESC', width: 90, sortable: true, dataIndex: 'YCSET_DESC',editor: 'textfield'},
                  {header: 'YCSET_CCY', width: 80, sortable: true, dataIndex: 'YCSET_CCY'},
                  {header: 'YCSET_COMP_MODE', width: 90, sortable: true, dataIndex: 'YCSET_COMP_MODE'},
                  {header: 'YCSET_YCTYPE', width: 100, sortable: true, dataIndex: 'YCSET_YCTYPE',editor: 'textfield'},
                  {header: 'YCSET_INTBASIS', width: 100, sortable: true, dataIndex: 'YCSET_INTBASIS'},
                  {header: 'YCSET_DISC_FACTOR', width: 150, sortable: true, dataIndex: 'YCSET_DISC_FACTOR',editor:'textfield'}
              ],
              dockedItems: [{
                  xtype: 'pagingtoolbar',
                  store: store,   
                  dock: 'bottom',
                  displayInfo: true
                  //plugins: Ext.create('Ext.ux.ProgressBarPager', {})
              }],
              viewConfig: {
                  forceFit: true,
                  stripeRows: true,
                  enableTextSelection: true
              },
  
              height:267,
              autoExpandColumn: 'ycset_id',
              autoScroll: true,
              width:620
  
          });
  </code></pre>
  
  <p><strong>USCities. java</strong></p>
  
  <pre><code> package pack1;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.ArrayList;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import net.sf.json.JSONObject;
  import net.sf.json.JSONSerializer;
  
  import pack2.City;
  import pack2.CityInformation;
  import com.google.gson.Gson;
  import com.google.gson.JsonArray;
  import com.google.gson.JsonElement;
  import com.google.gson.JsonObject;
  
  public class USCities extends HttpServlet {
  private static final long serialVersionUID = 1L;
  private String storeId;
  public USCities() {
  super();
  }
  
  protected void doGet(HttpServletRequest request, HttpServletResponse response) {           
  doPost(request,response);
  }
  
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  storeId = request.getParameter("store_id");
  String start = request.getParameter("start");
  String limit = request.getParameter("limit");
  System.out.println(storeId);
  
  PrintWriter out = response.getWriter();
  response.setContentType("text/html");
  
  CityInformation cityInformation = new CityInformation();
  
  ArrayList&lt;City&gt; cityList = cityInformation.getCities(storeId,start,limit);
  System.out.println("cityList----------"+cityList);
  Gson gson = new Gson();
  JsonArray arrayObj = new JsonArray();
  for(int i=0;i&lt;cityList.size();i++){
    System.out.println("cityList-----1-----"+cityList.get(i).toString());
  City city = cityList.get(i);
  JsonElement cityObj = gson.toJsonTree(city); 
  System.out.println("Json Element----"+cityObj);
  arrayObj.add(cityObj);
  }
  
  JsonObject myObj = new JsonObject();
  myObj.addProperty("success", true);
  myObj.add("cityList", arrayObj);
  myObj.addProperty("totalCount", limit);
  
  out.println(myObj.toString());
  out.close();
  
  }
  
   private void updateyield(HttpServletRequest request, HttpServletResponse response) throws IOException{
  
   //get the record Information 
   String recordInfo = request.getParameter("recordInfo");
  
   //parse JSON object and populate the Customer bean 
   JSONObject yieldObj = (JSONObject) JSONSerializer.toJSON(recordInfo); 
   City city = (City) JSONObject.toBean(yieldObj, City.class);
  
   CityInformation cityInformation = new CityInformation();
  
  boolean success = cityInformation.updategrid(storeId, city);
  
   PrintWriter out = response.getWriter();
   response.setContentType("text/html");
  
   //send response back whether the request was successful
   JSONObject myObj = new JSONObject();
   myObj.put("success", success);
   out.println(myObj.toString());
   out.close();
  
   }
   }
  </code></pre>
  
  <p>*<strong><em>City.java</em>*</strong></p>
  
  <pre><code> package pack2;
  import java.sql.Connection;
   import java.sql.DriverManager;
  import java.sql.PreparedStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.ArrayList;
  
  public class CityInformation {   
  
  Connection conn = null;             
  PreparedStatement stmt = null;      
  String sql = null;
  
  public ArrayList&lt;City&gt; getCities(String storeId, String start, String limit) {  
  
  ArrayList&lt;City&gt; cityList = new ArrayList&lt;City&gt;(); 
  
  
  try {       
  
    Class.forName("oracle.jdbc.driver.OracleDriver");
   conn =      DriverManager.getConnection("jdbc:oracle:thin:@172.16.3.150:1521:NABA","STEN","STEN");
    System.out.println("connection establisted ");
   sql="SELECT   YCSET_ID,YCSET_DESC,YCSET_CCY,YCSET_COMP_MODE,YCSET_YCTYPE,YCSET_INTBASIS,YCSET_DISC_FACTOR FROM YCSET_MASTER";
   stmt = conn.prepareStatement(sql);
   stmt.setInt(1,Integer.parseInt(storeId));
   stmt.setInt(2, Integer.parseInt(start));
   stmt.setInt(3, Integer.parseInt(limit));
    ResultSet rs = stmt.executeQuery();  
  
   while(rs.next()){ 
   City city = new City();
  
   city.setYCSET_ID(rs.getString("YCSET_ID"));
   city.setYCSET_DESC(rs.getString("YCSET_DESC").trim());
   city.setYCSET_CCY(rs.getString("YCSET_CCY").trim());
   city.setYCSET_COMP_MODE(rs.getString("YCSET_COMP_MODE").trim());
   city.setYCSET_YCTYPE(rs.getString("YCSET_YCTYPE"));
   city.setYCSET_INTBASIS(rs.getString("YCSET_INTBASIS"));
   city.setYCSET_DISC_FACTOR(rs.getString("YCSET_DISC_FACTOR").trim());
   cityList.add(city);
  
   }                                                                          
  
    rs.close();                                                                
    stmt.close();                                                              
    stmt = null;                                                               
  
  
     conn.close();                                                              
     conn = null;                                                    
  
      }                                                                
     catch(Exception e){
    System.out.println(e);
    }                       
  
      finally {                                                        
    if (stmt != null) {                                             
    try {                                                          
     stmt.close();                                                 
     } catch (SQLException sqlex) {                                 
  
    }                                                              
  
    stmt = null;                                             
    }                                                         
  
    if (conn != null) {                                       
   try {                                                    
   conn.close();                                           
   } catch (SQLException sqlex) {                           
  
   }                                                        
  
   conn = null;                                             
   }                                                         
  }               
  
   return cityList;
  
   }   
    public boolean updategrid(String storeId, City city) { 
  
   boolean success = true;
  
   try {      
       //Context ctx = (Context) new InitialContext().lookup("java:comp/env");
       //conn = ((DataSource) ctx.lookup("jdbc/mysql")).getConnection(); 
       Class.forName("oracle.jdbc.driver.OracleDriver");
       conn = DriverManager.getConnection("jdbc:oracle:thin:@172.16.3.196:1521:NABARDRM","NABARD_STENV_2","NABARD_STENV_2");
  
       sql = "UPDATE YCSET_MASTER set YCSET_ID = ?, YCSET_DESC = ?, YCSET_YCTYPE = ?, YCSET_DISC_FACTOR = ?" +
       " where store_id = ? and YCSET_ID = ?";
       stmt = conn.prepareStatement(sql);
       stmt.setString(1,city.getYCSET_ID()); 
       stmt.setString(2,city.getYCSET_DESC());
       stmt.setString(6,city.getYCSET_YCTYPE());
       stmt.setString(8,city.getYCSET_DISC_FACTOR());
  
       stmt.executeUpdate();
  
       stmt.close();                                                             
       stmt = null;                                                              
       conn.close();                                                             
       conn = null;                                                   
  
     }                                                               
     catch(Exception e){
  
       success = false;
       System.out.println(e);
  
     }                      
  
        finally {                                                       
  
         if (stmt != null) {                                            
           try {                                                         
               stmt.close();                                                
           } catch (SQLException sqlex) {                                
               // ignore -- as we can't do anything about it here           
           }                                                             
  
           stmt = null;                                            
         }                                                        
  
        if (conn != null) {                                      
           try {                                                   
               conn.close();                                          
           } catch (SQLException sqlex) {                          
               // ignore -- as we can't do anything about it here     
           }                                                       
  
           conn = null;                                            
       }                                                        
     }              
  
     return success;
  
    }  
  
   }   
  </code></pre>