ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/SpecificationAttribute/_CreateOrUpdate.TabOptions.cshtml
@model SpecificationAttributeModel
@{
    if (!String.IsNullOrEmpty(Model.Id))
    {

<div class="panel panel-default">
    <vc:admin-widget widget-zone="specification_attribute_details_options_top" additional-data="null" />
    <div class="panel-body">
        <div id="specificationattributeoptions-grid"></div>
    </div>
    <div class="panel-footer">
        <button type="submit" id="btnAddNewOption" onclick="javascript:OpenWindow('@(Url.Action("OptionCreatePopup", "SpecificationAttribute", new { specificationAttributeId = Model.Id, btnId = "btnRefresh", formId = "specificationattribute-form" }))', 800, 350, true); return false;" class="k-button"><i class="fa fa-plus"></i>&nbsp;@T("Admin.Catalog.Attributes.SpecificationAttributes.Options.AddNew")</button>
        <input type="submit" id="btnRefresh" style="display: none" />
    </div>
    <vc:admin-widget widget-zone="specification_attribute_details_options_bottom" additional-data="Model" />
</div>

<script>
            $(document).ready(function () {
                $("#specificationattributeoptions-grid").kendoGrid({
                    dataSource: {
                        transport: {
                            read: {
                                url: "@Html.Raw(Url.Action("OptionList", "SpecificationAttribute", new { specificationAttributeId = Model.Id }))",
                                type: "POST",
                                dataType: "json",
                                data: addAntiForgeryToken
                            },
                            destroy: {
                                url: "@Html.Raw(Url.Action("OptionDelete", "SpecificationAttribute"))",
                                type: "POST",
                                dataType: "json",
                                data: addAntiForgeryToken
                            }
                        },
                        schema: {
                            data: "Data",
                            total: "Total",
                            errors: "Errors",
                            model: {
                                id: "Id"
                            }
                        },
                        error: function(e) {
                            display_kendoui_grid_error(e);
                            // Cancel the changes
                            this.cancelChanges();
                        },
                        serverPaging: true,
                        serverFiltering: true,
                        serverSorting: true
                    },
                    pageable: {
                        refresh: true,
                        numeric: false,
                        previousNext: false,
                        info: false
                    },
                    editable: {
                        confirmation: true,
                        mode: "inline"
                    },
                    scrollable: false,
                    columns: [{
                        field: "Name",
                        title: "@T("Admin.Catalog.Attributes.SpecificationAttributes.Options.Fields.Name")",
                        template: "<a class='k-link' onclick=\"javascript:OpenWindow('@Url.Action("OptionEditPopup", "SpecificationAttribute")/#=Id#?btnId=btnRefresh&formId=specificationattribute-form', 800, 450, true); return false;\">#=kendo.htmlEncode(Name)#</a>"
                    }, {
                        field: "DisplayOrder",
                        title: "@T("Admin.Catalog.Attributes.SpecificationAttributes.Options.Fields.DisplayOrder")",
                        width: 100
                    }, {
                        field: "NumberOfAssociatedProducts",
                        title: "@T("Admin.Catalog.Attributes.SpecificationAttributes.Options.Fields.NumberOfAssociatedProducts")",
                        width: 150
                    }, {
                        command: {name: "destroy", text: "@T("Admin.Common.Delete")"},
                        title: "@T("Admin.Common.Delete")",
                        width: 100
                    }]
                });
            });
</script>
        <script>
            $(document).ready(function () {
                $('#btnRefresh').click(function () {
                    //refresh grid
                    var grid = $("#specificationattributeoptions-grid").data('kendoGrid');
                    grid.dataSource.read();

                    //return false to don't reload a page
                    return false;
                });
            });
        </script>
    }
    else
    {
        <div class="note note-info">
            @T("Admin.Catalog.Attributes.SpecificationAttributes.Options.SaveBeforeEdit")
        </div>
    }
    
}