does anybody know how to add search highlight and add column ?

does anybody know how to add search highlight and add column ?

13husen13husen Posts: 3Questions: 1Answers: 0

hello there i am new for using datatables,so here i have a serverside table and i want it to highlight when i am search on it,and also i want to add an id column,so when the table has new row,then the number increase automatically,sorry if this a silly question

Answers

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

    You need to supply more information.
    What do you mean by "a serverside table"? If you have a database table it should already have an auto-incrementing "id" field.
    What do you mean by "highlight when i am search on it"?

  • 13husen13husen Posts: 3Questions: 1Answers: 0

    well you know,the one that use ajax and json,so that it will take the data from database,but there's a problem,i want to add new column,not from the database,but from the datatables,when i add new table header,there's a warning that says "dataTables warning: table id=example - Requested unknown parameter '14' for row 0, column 14.",and what i mean highlight is that when i am search on the datatables you will get the result based on the keywords that you type,but it doesn't highlight,so i hear there's a new plugin called "mark.js" that can help your search result highlighted,but i can't use that

  • allanallan Posts: 63,552Questions: 1Answers: 10,476 Site admin

    @tangerine was asking for clarification of if you are using client-side or server-side processing - see the manual for information on them.

    To answer your question, have you included a search highlighting plug-in such as this one?

    Can you please link to a test case showing the issue so we can help to resolve it. You say you can't use mark.js - why not? The forum rules ask for a test case so we can get all the information we need in order to be able to offer some help.

    Allan

  • 13husen13husen Posts: 3Questions: 1Answers: 0
    edited June 2017

    so this is just pieces of my code

        <script type= 'text/javascript'>
            $(document).ready(function () {
                var t = $('#example').DataTable({
                    "processing": true,
                    "mark":true,
                    "serverSide": true,
                    "order": [[ 4,"desc" ]],
                    "columnDefs": [
                {
                    "targets": [ 1 ],
                    "visible": false,
                    "searchable": false
                 }],
                    "ajax": { "url" :"http://localhost/code/index.php/min/cd" }   
    
                  });
    
                 $("#clik").click(function(){
                  swal({
                  title: 'Peringatan!',
                  text: "Apakah kamu yakin ingin keluar?",
                  type: 'warning',
                  showCancelButton: true,
                  confirmButtonColor: '#3085d6',
                  cancelButtonColor: '#d33',
                  confirmButtonText: 'Yes!'
            }).then(function () {
                location.href="http://localhost/code/index.php/login/logout"
            })
            })
            });
    
        </script>
    

    it look's no problem first, and of course i include to cdn mark.js to,i thought that it work's,but then the search field is completely disabled -_-,anyone can help me?

  • allanallan Posts: 63,552Questions: 1Answers: 10,476 Site admin

    Sure. Happy to help - please link to a test case as I've already requested. That will let us see and diagnose the issue.

    Allan

This discussion has been closed.