Sortable GridView

I’m still migrating from yii to yii2 and now I am working on the sorting of an GridView with ajax.

I decided to use kotchuprik/yii2-sortable-widgets because of the UI, but the documentation lacks a bit, if everything works on sorting with JS, but the new order isn’t saved to the database. There is no error in the JS console, the post request looks good, so far. Did anyone use this extension and know what is wrong?

View:




echo GridView::widget([ 

		'dataProvider' => $dataProvidel, 

		'columns' => [ 

			... 					

		], 

		'options' => [

			'data' => [

				'sortable-widget' => 1,

				'sortable-url' => \yii\helpers\Url::toRoute(['/../sorting']),

			]

		],		


	]); 



Controller:




public function actions()

{

return [

   'sorting' => [

       	    'class' => \kotchuprik\sortable\actions\Sorting::className(),

			'query' => BrancheCheckliste::find(),

			'orderAttribute' => 'position',

		],

	]; 

}

model BrancheCheckliste:




public function behaviors() {

    	return [

            'sortable' => [

            	'class' => \kotchuprik\sortable\behaviors\Sortable::className(),

		'query' => self::find(),

            	'orderAttribute' => 'position',

	],

];    

}



What does work is saving the right value in my position field on creating new entries, this code comes from the behavior.

Thanks!

It’s handled in github as a bug.

BTW: It’s really sad that some features habe been taken out off yii2, so that we have to use extensions, because they are sometimes buggy and not very well documented, and often there are more then one extension for one feature, so it’s not easy which one to take…