I am trying to sort columns and i require the render function. render is returning a JST template

I am trying to sort columns and i require the render function. render is returning a JST template

sudiptamsudiptam Posts: 1Questions: 1Answers: 0
edited March 2019 in Free community support

Here's the code format:

      columnDefs:[
        {
          render: ( data, type, row ) =>
            JST['templates/common/user_info'](user: data, name: 'user_name')
          targets: 0
          className: "text-left"
          width: "25%"
          createdCell: (td, cellData, rowData, row, col) => 
            console.log col
            $(td).attr("data-order", @toTitleCase(cellData.name))
            console.log $(td).attr("data-order", @toTitleCase(cellData.name))                                    
        },
        {
          render: ( data, type, row ) =>
            if data
              JST['templates/common/user_info'](user: data, name: 'manager_name')
            else
              '-'
          targets: 1
          className: "text-left"
          width: "25%"
        },
        {
          render: ( data, type, row ) =>
            JST['templates/dashboards/meeting_cell'](model: data, key: 'all_meetings', status: 'all')
          targets: 2
          className: "text-left"
          width: "12.5%"
        },
        {
          render: ( data, type, row ) =>
            JST['templates/dashboards/meeting_cell'](model: data, key: 'completed', status: 'completed')
          targets: 3
          className: "text-left"
          width: "12.5%"
        },
        {
          render: ( data, type, row ) =>
            JST['templates/dashboards/meeting_cell'](model: data, key: 'pending', status: 'pending')
          targets: 4
          className: "text-left"
          width: "12.5%"
        },
        {
          render: ( data, type, row ) =>
            JST['templates/dashboards/meeting_cell'](model: data, key: 'missed', status: 'missed')
          targets: 5
          className: "text-left"
          width: "12.5%"
        }
      ]

Note: i tried with createdCell but seems to inaffective. I need to render the template anyhow as because my template contains the customised UI. Please give suggestions where it is wrong. I am able to sort it from server-side but on again datatable sorting brings random names instead of sorted ones.Above code is in coffeescript.

  toTitleCase: (str) ->
    str.replace /(?:^|\s)\w/g, (match) ->
      match.toUpperCase()

this function i have to make all the names appear in similar styles of converting the characters to uppercases.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @sudiptam ,

    At a glance, it looks like you're missing commas from the end of all the lines in columnDefs. If that doesn't resolve it, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.