title: Adding search field to gson jtable
body: <p>I am attempting to add a search field on a specific column in a jtable that I have.  I'm currently using gson in order to pass json data.  Here is my controller:</p>
  
  <pre><code>public class gsonTestController extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      public void doPost(HttpServletRequest request,
                  HttpServletResponse response) throws ServletException, IOException {
  
     String action = request.getParameter("action");
     if ( action != null) 
     {
          List&lt;Student&gt; studentList = new ArrayList&lt;Student&gt;();
  
          Gson gson = new GsonBuilder().setPrettyPrinting().create();
          response.setContentType("application/json");
  
          if (action.equals("list")) 
          {
                  try
                  {                                                                       
                  // Add data to Student list
                  studentList.add(new Student(1, "Grover", "IT", "xyz@xyz.com"));
                  studentList.add(new Student(2, "Bugs Bunny", "ECE", "xyz@gmail.com"));
                  studentList.add(new Student(3, "Taz", "MECH", "abc@gmail.com"));
                  studentList.add(new Student(4, "Cookie Monster", "ECE", "efg@gmail.com"));
                  studentList.add(new Student(5, "Billy the Kid", "CSC", "xyz@gmail.com"));
                  studentList.add(new Student(6, "Dustin Hoffman", "CSC", "123@gmail.com"));
                  studentList.add(new Student(7, "Obama", "ECE", "789@gmail.com"));
                  studentList.add(new Student(8, "Adam Sandler", "ECE", "123@gmail.com"));
                  studentList.add(new Student(9, "Pikachu", "IT", "xyz@gmail.com"));
  
                  // Convert Java Object to Json
                  String jsonArray = gson.toJson(studentList);
  
                  //Return Json in the format required by jTable plugin
                  jsonArray="{\"Result\":\"OK\",\"Records\":"+jsonArray+"}";
                  System.out.println(jsonArray);
                  response.getWriter().print(jsonArray);
                  }
                  catch(Exception ex){
                          String error="{\"Result\":\"ERROR\",\"Message\":"+ex.getMessage()+"}";
                          response.getWriter().print(error);
                  }                               
                  }
              }
           }
  }
  </code></pre>
  
  <p>This accesses Student.java (basic getter/setter methods) and at the end, passes the json-ified data to the following script on the jsp:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $(document).ready(function() {
                  $('#StudentTableContainer').jtable({
                          title : 'Students List',
                          sorting: true,
                          defaultSorting: 'Name',
                          actions : {
                                  listAction: 'gsonTestController?action=list',
                                  createAction:'gsonTestController?action=create',
                                  updateAction: 'gsonTestController?action=update',
                                  deleteAction: 'gsonTestController?action=delete'
                          },
                          fields : {
                                  studentId : {
                                          title : 'Student Id',
                                          width : '30%',
                                          key : true,
                                          list : true,
                                          create : true
                                  },
                                  name : {
                                          title : 'Name',
                                          width : '30%',
                                          edit : false
                                  },
                                  department : {
                                          title : 'Department',
                                          width : '30%',
                                          edit : true
                                  },
                                  emailId : {
                                          title : 'Email',
                                          width : '20%',
                                          edit : true
                                  }
                          }
                  });
                  $('#StudentTableContainer').jtable('load');
          });
  &lt;/script&gt;
  </code></pre>
  
  <p>The html is simply:</p>
  
  <pre><code>&lt;div id="StudentTableContainer"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>When reading through the jtable documentation for filters, I was unable to find any sample code for implementing a filter using gson (as opposed to a dedicated server-side technology like php or ASP.NET).  Their filter demo page is located here:  <a href="http://www.jtable.org/Demo/Filtering" rel="nofollow">http://www.jtable.org/Demo/Filtering</a></p>
  
  <p>Now granted, my controller is just using hard-coded data for the time being since I don't have a datasource set up yet.  Eventually all of the data will be accessed via a DAO (in Spring MVC).  I am unfamiliar with ASP.NET, but I gather from the demos on the page that the basic idea is to set variables and filter the data based on the user-inputted values.  I'm just unsure as to how I would go about setting that up in my current structure.  I read through the gson user guide but I'm not really sure what I need to look for.  Any pointers are greatly appreciated.</p>