do not show row if id in list

do not show row if id in list

painxurekpainxurek Posts: 3Questions: 0Answers: 0

i want to check if id in crawled list if so do not render that row any help

json

{
    data: [
    {
    id: 20,
    title: "Monster House",

    image_file: "http://127.0.0.1:7000/images/99969.jpeg"
}],
    crawled: [1,5,20]
    }

ajax

let table = $('#ecommerce-product-list').DataTable({

    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "/mage/ajax_mage_all/",
        "type": "GET"
    },
    
    "columns": [
        {data: "id"},
        {data: "image_file"},
        {"data": "title",
            className:"text-center"
        },
  
    ]
        });

Replies

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954
    edited May 2022

    Since you are using server side processing (serverSide: true) your server script will need to filter the rows you don't want displayed. Are you using Datatables supplied server side processing scripts or your own?

    Kevin

  • painxurekpainxurek Posts: 3Questions: 0Answers: 0

    i'm trying to avoid filtering using server side if possible

  • kthorngrenkthorngren Posts: 21,344Questions: 26Answers: 4,954

    When you have server side processing all searching, sorting and paging functions are performed by the server script. There is no option for performing filtering in the client. Maybe you can use client side processing?

    One option, which is not supported by Datatables, is to use something like jQuery hide() to hide the row elements in the DOM. You can use the draw event to loop through all the rows in the client using rows().every(). In the loop do your comparison and hide the matching rows with jQuery hide().

    One caveat is that Datatables knows nothing about using jQuery hide(). If you have a page length of 10, for example, and hide one row the table will display only 9 rows.

    Kevin

  • painxurekpainxurek Posts: 3Questions: 0Answers: 0

    alright i'll try server side then , tnx for explain

Sign In or Register to comment.