Does anyone have an example of using the unique() function?

Does anyone have an example of using the unique() function?

jawz302jawz302 Posts: 15Questions: 5Answers: 0

I would like to make a specific column only display an End Model once. Or is there a way to pull the data into the Datatable using Select Distinct in the query, maybe?

Answers

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

    Hi @jawz302 ,

    Here's an example of unique() here.

    If you want to remove rows, to only show unique values in a certain column, you would need to use row().remove(), as I don't believe there's any other way of hiding it.

    Hope that helps,

    Cheers,

    Colin

  • jawz302jawz302 Posts: 15Questions: 5Answers: 0

    Does unique even do what I am trying to do which is not displaying duplicate records in a specific column?

  • jawz302jawz302 Posts: 15Questions: 5Answers: 0

    I cannot for the life of me figure out where to place it in my code.

  • kthorngrenkthorngren Posts: 21,449Questions: 26Answers: 4,975

    specific column only display an End Model once

    I'm not sure what this means but if you have duplicate data in a column you might be able to use columns.render to display the data once.

    Or is there a way to pull the data into the Datatable using Select Distinct in the query

    This would be up to your server script and database. Probably the way I would go if possible.

    Kevin

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

    Yep, unique() isn't what you want, or not on its own at least. As Kevin said, the best place to ensure uniqueness in the data is for the server to do that kind of stuff, and only send what it wants displayed. If you have to do it on the client, you can either manipulate the Ajax response, removing duplicate rows before it gets passed on to DataTables, or an initComplete or init callback.

    Cheers,

    Colin

This discussion has been closed.