The values ​​are not populated in the jquery database for a G…

综合技术 2018-03-07

I am fetching a list of values from the controller-action
to load into the data-table
.I have checked that values are getting fetched succesfully from my controller action, but the values are not getting load ed into the data-table
.And it shows

No data available

Here is my Controller.

package com.standout.utilityapplication
import grails.plugin.springsecurity.annotation.Secured

@Secured(['ROLE_ADMIN'])
class ReportController {
    AdminService adminService
    def report() { 

        println ("--Inside ReportController");
    }
    def searchAjax(){
        String criteria = params.search_criteria
        println ("criteria "+criteria)
        if(criteria.equalsIgnoreCase("Employee ID")){
        def resultSet = adminService.getReportById(params)
        println("----------------+++++ "+resultSet)
        [bill_details:resultSet]
        }

}
}

Here is my GSP.


   Report
   
   
   
   
   

function displayTable(){
    $(function() {
    $('#example').DataTable();
    })
    document.getElementById('reportSearch').style.display = ''

}
    





Employee Id Bill Date Amount No. of Persons Bank Submission Date Bank Submission Status Bill Date Reimbursed Restaurant Name Team
Employee Id Bill Date Amount No. of Persons Bank Submission Date Bank Submission Status Bill Date Reimbursed Restaurant Name Team
${it.employee_id} ${it.bill_submitted_dt} ${it.amount} ${it.number_of_persons} ${it.presented_bank_dt} ${it.presented_bank_fl} ${it.receipt_dt} ${it.reimbursed} ${it.restaurant_name} ${it.team}


Could anyone tell me what to do?

Please try using below code snippest.

html-table
content from gsp
file You can add other custom things to the table as per your wish.

Branch Name User Name First Name Last Name Contact Number

jquery
content for loading / pouplating
data in the data-table

var userDetailsDataTable = "";

userDetailsDataTableReload :  function(){

userDetailsDataTable = $('#userDataTable').DataTable();
userDetailsDataTable.destroy();

userDetailsDataTable = $('#userDataTable').DataTable({
    "ajax": '../restaurantManagement/fetchUserDetails'
});

}

from here, we are giving call to the controller action fetchUserDetails

controller-action
content

Map userDetailsMap      =   [:]

    List userDetailsList    =   userManagementService.fetchAllUsersByRestaurantId(restaurantId)

    userDetailsMap << [data : userDetailsList]

    render userDetailsMap as JSON

Let me know if it gives you problem.

您可能感兴趣的

Mailing it out with Mailgun! Last week, we started our exploration of the world of APIs by integrating Haskell with Twilio. We were able to send a basic SMS message, and then cre...
Data acquisition in R (3/4) R is an incredible tool for reproducible research. In the present series of blog posts I want to show how one can easily acquire data within an R ses...
4 Things You Can Do with Alibaba Cloud PolarDB During the PolarDB session of the 2017 Computing Conference, Alibaba Cloud's high level Technical Expert He Jun delivered a speech on the features and...
Elasticsearch moved into the top 10 most popular d... byMatthias Gelbmann, 3 July 2017 Tags : Elasticsearch Elasticsearch saw a steady growth of popularity in the last years. It is ...
人工智能当道,你离失业还有多远 人工智能当道,你离失业还有多远 当今社会最火爆的两个话题,一个是人工智能,一个是云计算。今天我们来聊聊人工智能。近年来,人工智能在国家和社会的持续关注下得到了大力的发展,展望未来,以工业4.0 为代表的智能技术将影响包括中国在内的全球劳...