#pragma checksum "C:\Users\lukanova\source\repos\GridValidationDemo\Views\Home\Index.cshtml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "5232e7c9b4d3ede3a49614227ea35eb8416f3e25"
// <auto-generated/>
#pragma warning disable 1591
[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Home_Index), @"mvc.1.0.view", @"/Views/Home/Index.cshtml")]
namespace AspNetCore
{
    #line hidden
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.Rendering;
    using Microsoft.AspNetCore.Mvc.ViewFeatures;
#nullable restore
#line 1 "C:\Users\lukanova\source\repos\GridValidationDemo\Views\_ViewImports.cshtml"
using GridValidationDemo;

#line default
#line hidden
#nullable disable
#nullable restore
#line 2 "C:\Users\lukanova\source\repos\GridValidationDemo\Views\_ViewImports.cshtml"
using Kendo.Mvc.UI;

#line default
#line hidden
#nullable disable
    [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"5232e7c9b4d3ede3a49614227ea35eb8416f3e25", @"/Views/Home/Index.cshtml")]
    [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@"SHA1", @"61e99918c5be54619382641bba93775f8d9f0a95", @"/Views/_ViewImports.cshtml")]
    public class Views_Home_Index : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
    {
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#nullable restore
#line 1 "C:\Users\lukanova\source\repos\GridValidationDemo\Views\Home\Index.cshtml"
  
    ViewData["Title"] = "Home Page";

#line default
#line hidden
#nullable disable
            WriteLiteral("\r\n<div class=\"row\">\r\n    <div class=\"col-xs-18 col-md-12\">\r\n        ");
#nullable restore
#line 7 "C:\Users\lukanova\source\repos\GridValidationDemo\Views\Home\Index.cshtml"
    Write(Html.Kendo().Grid<GridValidationDemo.Models.OrderViewModel>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Select().Title("Select Main Location").Width(50).HeaderHtmlAttributes(new { style = "pointer-events:none" });
                    columns.Bound(p => p.OrderID).Filterable(false);
                    columns.Bound(p => p.Freight);
                    columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
                    columns.Bound(p => p.Code);
                    columns.Bound(p => p.ShipCity);
                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(150);
                })
                .ToolBar(toolbar => toolbar.Create())
                .Pageable()
                .Editable(editable => editable.Mode(GridEditMode.PopUp).Window(w => w.Title("Create/Edit Location").Height(600).Width(600).Scrollable(true)))
                .Sortable(Sortable => Sortable.AllowUnsort(true))
                .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
                .Scrollable()
                .Filterable()
                .HtmlAttributes(new { style = "height:550px;" })
                .Events(ev => ev.Edit("onGridEdit"))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .PageSize(20)
                    .Model(m=>
                    {
                        m.Id(id => id.OrderID);
                        m.Field(id => id.OrderID).Editable(false);
                    })
                    .Read(read => read.Action("Orders_Read", "Grid"))
                    .Update(u => u.Action("UpdateOrders", "Grid"))
                    .Create(c => c.Action("CreateOrders", "Grid"))
                    .Destroy(destroy => destroy.Action("DestroyOrders", "Grid"))
                )
		);

#line default
#line hidden
#nullable disable
            WriteLiteral("\r\n    </div>\r\n</div>\r\n\r\n");
            DefineSection("scripts", async() => {
                WriteLiteral(@"
    <script>
    //adding remote rule to handle validation based on Remote attribute set in the model.
        $(document).ready(function () {

        $.extend(true, kendo.ui.validator, {
            rules: {
                remote: function (input) {
                    if (input.is(""[name=Code]"") && input.val()) {
                        if (input.val() == """" || !input.attr(""data-val-remote-url"")) {
                            return true;
                        }

                        if (input.attr(""data-val-remote-recieved"")) {
                            input.attr(""data-val-remote-recieved"", """");
                            return !(input.attr(""data-val-remote""));
                        }

                        input.attr(""data-val-remote-requested"", true);

                        var recordID = $(""input[name='OrderID']"").val();
                        var recordCode = input.val();
                        $.ajax({
                            url: '");
#nullable restore
#line 68 "C:\Users\lukanova\source\repos\GridValidationDemo\Views\Home\Index.cshtml"
                             Write(Url.Action("IsCode_Available", "Grid"));

#line default
#line hidden
#nullable disable
                WriteLiteral(@"',
                            type: ""GET"",
                            async: false,
                            data: { ""Code"": recordCode, ""id"": recordID},
                            success: function (data) {
                                if (data == true) {
                                    input.attr(""data-val-remote"", """");
                                    $("".k-grid-update"").show();
                                }
                                else {
                                    input.attr(""data-val-remote"", data);
                                    $("".k-grid-update"").hide();
                                }
                                input.attr(""data-val-remote-recieved"", true);

                            },
                            error: function () {
                                input.attr(""data-val-remote-recieved"", true);
                            }
                        });
                        return true
                    }
    ");
                WriteLiteral(@"                return true
                }
            },
            messages: {
                remote: function (input) {
                    return input.attr(""data-val-remote"");
                }
            }
        });
        });

        function onGridEdit(e) {
            if (e.model.isNew()) {
                var newID = e.sender.dataSource.total();
                e.container.find('input#OrderID').val(newID);
            }
            e.container.find('input#OrderID').prop('disabled', true);
        }
    </script>
");
            }
            );
        }
        #pragma warning restore 1998
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
        [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
        public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<dynamic> Html { get; private set; }
    }
}
#pragma warning restore 1591
