Create Custom actionColumn with link


I have a problem.

I had 3 table to manage stock:

  • Items_table (item_id,label,stock…) the column stock has 0 as default value.

  • orders_table (order_id,at_date,status) the column status has 0 as default value.

  • orders_items_table(orderitem_id,order_id,item_id,quantity).

what I want to do is to create an actionStatus to validate order, by clicking on validate button in gridview. and this action must able to update column status from orders_table with 1, and after update column stock from Items_table quantity of appropriate item_id.

How can I do in my action and view to do that?

please save me!

Refer this page for adding new button action column in the grid view.

For example in the gridview you may can declare a class


    'status' => function ($url, $model, $key) {

        return $model->status === '0' ? Html::a('Update Status', 'javascript:void(0);',['class' => 'yourUIClass','data-id' => $model->id,'data-url' => Url::to('yourController/YourAction')]) : '';



In the javascript you may have some the event handlers to call to your ajax stuffs

$(document).on('click', '.yourUIClass',function(){

	var yourID = $(this).data('id');

	var YourURL = $(this).data('url');

	//Process your ajax stuffs here