How to add drop down list in jquery datatable

How to add drop down list in jquery datatable

HemangiHemangi Posts: 4Questions: 2Answers: 0

I have jquery plugin and i want to add drop down list in datatable and display data from database

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Ok, try initiating a table, then adding a dropdown list inside the table..

    Were here to help you with DT related peoblems, not walk you theough the entire process or teach you how to build it from scratch, thats what the documentation is fo, sorry bud.

    If youre stuck on something inparticular, related to DataTables, then let me know.

  • HemangiHemangi Posts: 4Questions: 2Answers: 0

    List<Trans> list = null;
    DataTable dataTable = new DataTable();
    String temp = (String) request.getParameter("days");
    switch(temp)
    {
    case "D" :
    list = DAO.getAllTransactions();
    break;
    case "W" :
    list = DAO.getWeeklyTransaction(temp);
    break;

            case "M" :
                list = DAO.getMonthlyTransaction(temp);
                break;               
        }
      dataTable.setAaData(list);
    Gson gson = new GsonBuilder().setPrettyPrinting().create();
    String json = gson.toJson(dataTable);
    response.setContentType("application/json");
    response.getWriter().print(json);
    

    I tried above code in servlet (create DAO class object and call java method) and i get data in JSON string and in jsp page i called (in anchor tag of dropdown list) href="/Admin_Dashboard/displayData?days=W" but i can't display data in jquery datatable while click on dropdown list

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    .... again, this has nothing to do with datatables.

  • jay113jay113 Posts: 8Questions: 2Answers: 0
    edited January 2016

    I have been trying to figure out how to do the same thing for quite some time now; any luck yet or have you found any additional resources on this topic?

  • glendersonglenderson Posts: 231Questions: 11Answers: 29

    If you move to creating your own ajax page, then you can craft anything to be returned in the json data that you send back to dataTables.

    you can then send
    {"data":[ ..., "<select><option val=\"1\">Pick 1<option>Pick 2<option>Pick 3</select>" ...}"

    dataTables will render HTML that's been passed in the json data.

  • jay113jay113 Posts: 8Questions: 2Answers: 0

    Can you reference a resource with a complete example that is easy to understand? Thanks.

This discussion has been closed.