Detected grid row js

Hey, I need detect amount rows in gridview. e.g I adds (select dropdownlist max 30) 20 records to database at max 30. who i can add. Now, if i would like add next record , in my select dropdown list should have max 10 records no 30 to choose.

Dropdownlist begin(max 30, but i can choose 20 too)

if i choose 20, so no i can only choose 10 because 30-20=10

I hope you understand


<?= GridView::widget([

'dataProvider' => $dataProvider,

'filterModel' => $searchModel,

'columns' => [

	'attr1',

	'attr2',

	[

	'attribute' => 'category_id',

	'value' => function ($m, $key) {

		return  Yii::t('app', $m::getCategoryById($m->category_id));

	},

	'filter' => Html::activeDropDownList($searchModel, 'category_id', $searchModel::getMax30(), ['class'=>'form-control', 'prompt' => 'all']),

	],

...



getMax30() - change name function, this method is in model, in this method you can put logic function to do what you want.

for example


Class Model {


function public getMax30(){


$model = Category::find()->asArray()->all()

$model[] = [add 10 elements]

}


}