0

enter image description here

I am using datatables for displaying data from mysql to frontend but i am stuck in displaying multiple designations in designation columns

code for initializing datatables

script(type='text/javascript').
      $(document).ready(function() {
      $('#mytab').DataTable({
       dom: 'Bfrtip',
       buttons: [
        'copy', 'csv', 'excel', 'pdf','print'
        ],

  });
      });

for retreiving data from database

 tbody
        if user
        each user, i in users
          tr.profiledata
            th= user.getDataValue('name') 
            th= user.getDataValue('stack_holder')
            th= user.getDataValue('client_name')
            th.reference #{user.getDataValue('reference')}
            th= user.getDataValue('document_type')
            th= user.getDataValue('service_type')
            th= user.getDataValue('year')
            th
              if((a = user.getDataValue('PO_start_date'))!=null)
                  |  #{a.getDate() + '-' + (a.getMonth()+1) + '-' + a.getFullYear()}
            th
              if((a = user.getDataValue('PO_end_date'))!=null)
                |  #{a.getDate() + '-' + (a.getMonth()+1) + '-' + a.getFullYear()}
            th
              if((a = user.getDataValue('reminder_date'))!=null)
                |  #{a.getDate() + '-' + (a.getMonth()+1) + '-' + a.getFullYear()} 

            if(user.getDataValue('transaction_tbls').length > 0)
              for tr in user.getDataValue('transaction_tbls')
                th= (tr['dataValues'])['designation']
                th= (tr['dataValues'])['quantity']
                th= (tr['dataValues'])['rate']
            else
              th
              th
              th
            th= user.getDataValue('signature_status')
            th= (a = user.getDataValue('createdAt')).getDate() + '-' + (a.getMonth()+1) + '-' + a.getFullYear()
            th= user.getDataValue('client') 
            th= user.getDataValue('contact') 
            th= user.getDataValue('contactperson') 
            th= user.getDataValue('contactnumber') 
            th= user.getDataValue('emailid') 
            th= user.getDataValue('period_of_contract')
            th= user.getDataValue(' payment_term')
            th= user.getDataValue('financial_year')    

I get object of my table like transaction_tbl:[] in response from server

11
  • Please share your code with us as an minimal reproducible example and not just an image of the result. Commented Aug 22, 2018 at 12:30
  • 1
    Don't add your code as a comment, edit your question Commented Aug 22, 2018 at 12:47
  • @PANKAJ DALVI, can you add jsfiddle link, where we can run code and identify where is error?. Commented Aug 22, 2018 at 15:07
  • do you want data to display like 'tester, developer, BDE' under same cell right? Commented Aug 22, 2018 at 15:12
  • Why don't you use AJAX option of DataTables? That way DataTables will manage the table itself. You will only need to return an array or object from the server.More on AJAX option Commented Aug 22, 2018 at 16:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.