to the require section of your composer.json file., (*6)
Usage
The usage is similar to default ListView Widget (http://www.yiiframework.com/doc-2.0/yii-widgets-listview.html), (*7)
You just need a dataProvider and prepare the item template for your model., (*8)
In clientOptions you can pass the Isotope options to modify the plugin behavior (see http://isotope.metafizzy.co/options.html), (*9)
The filterAttribute parameter is the attribute name of the model passed that will be used as class for the grid-item tag.
The attribute value can be an array or string of separated by spaces., (*10)
You can also attach a cssFile for styling the grid., (*11)
Exemple
We have this model:, (*12)
class MyElement extends \yii\base\Model
{
public $id;
public $name;
public $symbol;
public $number;
public $weight;
public $categories;
}
All models, views and CSS styles used for the exemple are inside the folder demo-data.
The template named index.php adds a filter buttons to test the filtering methods.
It's a similar exemple that it's explained inside the Isotope documentation (http://isotope.metafizzy.co/filtering.html), (*15)
registerJs('
var filterFns = {
// show if number is greater than 50
numberGreaterThan50: function() {
var number = $(this).find(".number").text();
return parseInt( number, 10 ) > 50;
},
// show if name ends with -ium
ium: function() {
var name = $(this).find(".name").text();
return name.match( /ium$/ );
}
};
$(".filters-button-group").on( "click", "button", function() {
var filterValue = $( this ).attr("data-filter");
// use filterFn if matches value
filterValue = filterFns[ filterValue ] || filterValue;
$("#w0 .grid").isotope({ filter: filterValue });
});
', $this::POS_END) ?>
$dataProvider,
'filterAttribute' => 'categories',
'itemView' => '_item',
'cssFile' => [
"@web/css/grid-demo.css"
]
]) ?>
You may also be interested in MatchHeight.js ListView widget:
https://github.com/nerburish/yii2-match-height-view, (*16)
The Versions
24/082016
dev-master
9999999-dev
ListView widget improved to use Isotope (http://isotope.metafizzy.co/)