I have to fetch collections details by ajax call and also apply a filter on it.

So I have created a controller add-on, call it by ajax and put below code in it.


    foreach ($collectionDataList as $item) {
        echo '<pre>'; print_r($item->data()); exit;

But I want to filter data by fields of the collection. So is there any where function or any other way?