How To Solve This ??

How To Solve This ??

harsha320harsha320 Posts: 2Questions: 1Answers: 0

DataTables warning: table id=example - Requested unknown parameter '1' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4

MY CONTROLLER ------

@RequestMapping(value = "/yourSpringRequestMappingValue", method = RequestMethod.GET)
@ResponseBody
String getJsonData(HttpServletRequest request,@RequestParam Integer id) {

       JsonObject data  = new JsonObject();
       Collection<JsonArray> allData = new ArrayList<JsonArray>();

       Integer displayLength = Integer.parseInt(request.getParameter("iDisplayLength"));
       Integer displayStart = Integer.parseInt(request.getParameter("iDisplayStart"));         
       Integer pageNumber = (displayStart+displayLength)/displayLength;
       String sortCol = request.getParameter("iSortCol_0");
       String sortDir = request.getParameter("sSortDir_0");
       String search = request.getParameter("sSearch_0");          

       System.out.println("id :-"+id);
       System.out.println("displayLength :-"+displayLength);
       System.out.println("displayStart :-"+displayStart);
       System.out.println("pageNumber :-"+pageNumber);
       System.out.println("sortCol :-"+sortCol);
       System.out.println("sortDir :-"+sortDir);
       System.out.println("search :-"+search);

       ApplicantOutreachMappingExample applicantOutreachMappingExample = new ApplicantOutreachMappingExample();
       com.sl1m.job.vo.outreach.ApplicantOutreachMappingExample.Criteria createCriteria = applicantOutreachMappingExample.createCriteria();
       createCriteria.andIntOutreachIntidEqualTo(id);
       long totalRecord = applicantOutreachMappingMapper.countByExample(applicantOutreachMappingExample);

       List<ApplicantOutreachMapping> ApplicantOutreachMappingList = applicantOutreachMappingMapper.selectByExampleLimit(id,displayLength, 0);

       List<com.sl1m.job.vo.outreach.Applicants> applicantsList = new LinkedList<com.sl1m.job.vo.outreach.Applicants>();

        for (ApplicantOutreachMapping applicantOutreachMapping : ApplicantOutreachMappingList) {
            //System.out.println(applicantOutreachMapping.getIntApplicantIntId());
            com.sl1m.job.vo.outreach.Applicants applicants = applicantsMapper.selectByPrimaryKey(applicantOutreachMapping.getIntApplicantIntId());
            for (com.sl1m.job.vo.outreach.Applicants applicant : applicantsList) {
                applicantsList.add(applicant);
            }               
        }

       for (int i = 0;i < applicantsList.size();i++) {
           JsonArray dataArray = new JsonArray();
           JsonPrimitive no = new JsonPrimitive("1");
           JsonPrimitive noKadPengenalan = new JsonPrimitive(applicantsList.get(i).getVarNric());
           JsonPrimitive nama = new JsonPrimitive(applicantsList.get(i).getVarName());             
           JsonPrimitive noTelefon = new JsonPrimitive(applicantsList.get(i).getVarTelephone());
           JsonPrimitive emel = new JsonPrimitive(applicantsList.get(i).getVarEmail());
           JsonPrimitive link = new JsonPrimitive("link");

          dataArray.add(no);
          dataArray.add(noKadPengenalan);
          dataArray.add(nama);
          dataArray.add(noTelefon);
          dataArray.add(emel);
          dataArray.add(link);

          allData.add(dataArray);
       }

       int echo = 0;

       data.addProperty("draw", pageNumber);
       data.addProperty("recordsTotal",totalRecord);
       data.addProperty("recordsFiltered", applicantsList.size());
       data.addProperty("aaData", allData.toString());
       data.addProperty("sEcho", echo + 1 );
       data.addProperty("iDisplayLength", displayLength);

       String JSON_DATA_AS_STRING = data.toString();

         return JSON_DATA_AS_STRING;            
   }

MY JSP ---

$(document).ready(function(){
$('#example').dataTable({
"processing": true,
"bServerSide": true,
"sAjaxSource": "${pageContext.request.contextPath}/yourSpringRequestMappingValue?id=${outreachid}",
"columns" : [ {
"title" : "No",
"class" : "center"},
{
"title" : "Kad Pengenalan",
"class" : "center"},
{
"title" : "Nama",
"class" : "center"},
{
"title" : "Telefon",
"class" : "center"},
{
"title" : "Emel",
"class" : "center"},
{
"title" : "Slip",
"class" : "center"},
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": 'default value of column'}],
});
});

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The link at http://datatables.net/tn/4 explains the diagnostic steps you should follow.

  • harsha320harsha320 Posts: 2Questions: 1Answers: 0

    My Complete Json Boject is desplaying in characters

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    If you provide link to a page showing the issue, I'd be happy to take a look and help debug it.

    Allan

This discussion has been closed.