Do not include some Object data source items

Do not include some Object data source items

Karl_SKarl_S Posts: 20Questions: 6Answers: 0

I have data coming with a field to Ignore the entry. Instead of deleting an entry, we mark it to be ignored. I would like to have these in my object which defines my data source as well as the items I am interested in:

     0: {name: 'Jen', type: 'Adult', ignore: false),
     1: {name: 'Harry', type: 'Adult', ignore: false),
     2: {name: 'Fred', type: 'Teen', ignore: true)

Is there any way to use the (very simplified) object above and display the first two items since ignore is false on these? I know I can limit it to show the name and type. If the third has ignore become true, I want to then display it as well. I may be counting, adding, or doing other things with the table items so I do not think I can hide the row. Nor do I want to create a second object with only the valid ones if I don't have to. I can if hat is the answer, though, and add any new ones or any to not ignore as needed.


  • kthorngrenkthorngren Posts: 7,742Questions: 25Answers: 1,719

    Not sure I understand your requirements but I will present a couple things that might help you.

    You can have the ignore true rows in your table and filter them using something like so they aren't shown when the table loads. You can still access the data and perform calculations.

    The data structure you show isn't supported by Datatables. You will need to change it to an array of objects as described here:

    If this doesn't help please provide more details of what you are trying to do.


  • colincolin Posts: 7,662Questions: 0Answers: 1,294
    edited September 2019

    Hi @Karl_S ,

    You could do something like this - it's from one of Kevin's other threads. In that example it's hiding null values, you could modify it to hide the row if ignore is true.



  • Karl_SKarl_S Posts: 20Questions: 6Answers: 0

    So the object data can't be a JavaScript Object but must be an array. It can, however, be an array of objects and when this is the case the key is used to identify which item goes in which column. I was trying to pas objects of an object.

  • kthorngrenkthorngren Posts: 7,742Questions: 25Answers: 1,719

    Yes, that is correct. Datatables expects an array of data. Each element in the array is a row. The row data can be either arrays or objects.


Sign In or Register to comment.