<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript("DisableBrand", "
function Disable(id){
    var r = confirm('Are you sure?');
    if(r==true)
    {
        jQuery.ajax({
          type  : 'post',
          data  : 'id=' + id,
          url  : $('#liveSite').val()+'index.php?r=masbrands/disable',
          success:function(){
                reloadTable('#tbl_Masbrands');
           }
        });
    }
};
", CClientScript::POS_HEAD);
?>

<script>
$(document).ready(function () {

    var table = $("#tbl_Masbrands").DataTable({

        scrollY: "645px",
        pageLength: 50,
        processing: true,
        serverSide: true,

        ajax: {
            url: "<?php echo Yii::app()->createUrl('masbrands/GetList') ?>",
            type: "POST"
        },

        fnCreatedRow: function (nRow) {
            $(nRow).addClass("context-menu");
        },

        fnRowCallback: function (nRow, aData) {
            AddContextMenu(nRow, aData);
        }
    });
});

function AddContextMenu(row, datas) {

    $(row).contextMenu({
        selector: 'td',

        items: {

            "edit": {
                name: "Edit",
                callback: function () {
                    loadPopupModal(
                        "masbrands/create&id=" + datas[2].id,
                        "Edit Brand",
                        "lg"
                    );
                }
            },

            "toggle": {
                name: (datas[2].status == "Y") ? "Disable" : "Enable",
                callback: function () {
                    Disable(datas[2].id);
                }
            }
        }
    });
}
</script>

<section class="panel">
    <header class="panel-heading clearfix panel-theame">
        <i class="fa fa-list"></i> Mas Brands

        <div class="pull-right">
             <a class="ad-btn" onclick="loadPopupModal('masbrands/create','Add New Brand','lg')">
                <i class="fa fa-plus"></i>
              </a>
        </div>
    </header>

    <div class="panel-body">
        <div class="custom-data-table">
            <table class="table table-hover table-bordered"
                   id="tbl_Masbrands" style="font-size:13px;">
                <thead>
                    <tr>
                        <th>SI No</th>
                        <th>Brand Name</th>
                    </tr>
                </thead>
            </table>
        </div>
    </div>
</section>