ARYA JAGANNATH Ответов: 0

Как передать значение из внутренней сетки в частичное представление Get Action в MVC с помощью Kendo UI ?


@model  KenPartner.Models.UploadDocumentViewModel
@{
    ViewBag.Title = "Applications";
}

<script>
    function UnitName(item) {
        debugger;
        var html = ""; //= //"<div>Hi</div>";
        for (var i = 0; i < item.UnitList.length; i++) {

            html += "<div>" + item.UnitList[i].UnitName + "</div>";
        }
        return html;

    }

    function onDataBound(e) {
        //alert(obj);
        debugger;
        var grid = this;
        var id = grid._cellId;
        var gridId = id.substring(0, id.lastIndexOf('active_cell') - 1);


        grid.tbody.find('tr').each(function (i) {


            debugger;

            var data = grid._data[i];

            debugger;
            $(this)[0].cells[5].innerHTML = "<img src='" + "/partnersite/images/Application/Document/" + data.FilePath + "'height='62' width='62' onerror=this.src='/images/user-default.png' />";

        });
    }
</script>


    <div style="margin-top:5px">

        <div class="row" style="margin-top:5px;display:block;margin-left:10px">
            <div id="divApplicantDtls" class="col-lg-11 col-md-11 col-sm-11">
                <div class="k-block">
                    @*<div class="k-header" style="height:35px">
                            Applications @(Html.Kendo().Button()
                           .Name("AddNew")
                           .Tag("a").HtmlAttributes(new { style = "float:right" })
                           .SpriteCssClass("k-icon k-i-plus")
                           .Content("Add New"))
                        </div>*@
                    @(Html.Kendo().Grid<KenPartner.Models.KenApplicationsViewModel>()
                                  .Name("gvApplications")
                                  .HtmlAttributes(new { style = "width:100%;height:450px" })
                                  .Columns(columns =>
                                                    {
                                                        columns.Template(model => model.PartnerId).Hidden();
                                                        columns.Template(model => model.ApplicantionId).Hidden();
                                                        columns.Bound(model => model.ApplicationNo);
                                                        columns.Bound(model => model.ApplicationFor).Title("Apply For");
                                                        columns.Bound(model => model.ApplicationStatus).Title("Status");
                                                        columns.Bound(model => model.PaymentStatus);
                                                        columns.Bound(model => model.AppMode).Title("Application Type");
                                                    })
                                .ClientDetailTemplateId("templates")
                                .DataSource(dataSource => dataSource
                                                          .Ajax()
                                                          .Read(read => read.Action("GetApplications", "Application")))

                                .Events(events => events.DataBound("dataBound"))
                                .Pageable()
                                .Scrollable()
                                .Selectable(selectable => selectable
                                                          .Mode(GridSelectionMode.Multiple))

                    )
                </div>
            </div>

            <script id="templates" type="text/kendo-tmpl">
                    <div class="k-header" style="height:35px">
                         @(Html.Kendo().Button()
                           .Name("AddNewDocument")
                           .Tag("a").HtmlAttributes(new { style = "float:right" })
                           .SpriteCssClass("k-icon k-i-plus")
                           .Content("Add New").ToClientTemplate())
                    </div>
                @(Html.Kendo().Grid<KenPartner.Models.UploadDocumentViewModel>()
            .Name("grid_#=ApplicantionId#")
            .Columns(columns =>
            {
                columns.Bound(o => o.ApplicationId).Hidden(true);
                columns.Bound(o => o.DocumentId).Hidden(true);
                columns.Bound(o => o.DocumentTypename).Title("DocumentType").Width(210);
                columns.Bound(o => o.DocumentName).Title("Document Name");
                columns.Bound(o => o.FileSize).Title("File Size(KB)");
                columns.Bound(p => p.FilePath).Title("Image").Width(80);
                columns.Command(command => command.Destroy().HtmlAttributes(new { @class = "btn-danger" }));

            })
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(10)
                        .Model(model => { model.Id(p => p.ApplicationId); model.Field(p => p.ApplicationId).DefaultValue(16000000); })
                        .Read(read => read.Action("DocumentsRead", "Upload", new { ApplicantionId = "#=ApplicantionId#" }))
                        .Destroy(delete => delete.Action("Documents_Delete", "Upload")))

                    .Pageable()

                    .Sortable()
                    .Selectable(selectable => selectable
            .Mode(GridSelectionMode.Multiple)).Events(ev => ev.DataBound("onDataBound"))
                    .ToClientTemplate()
                )
            </script>

        </div>


    </div>

    @(Html.Kendo().Window().Name("winSure")
                .Title("Create Application")
                .Visible(false)
                .Modal(true)
                .Draggable(false)
                .Width(500)
                .Position(settings =>
                          settings.Top(70).Left(200))
                          .Title("Edit your password")
                          .Content("loading user info...")
                          .LoadContentFrom("Documents", "Application")
                          .Iframe(true)
                          .Resizable()
                          .Draggable()
        )

<script>
    function dataBound() {
        debugger;
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>

<script>
    /* For Add New Documents*/
    $("#AddNewDocument").on("click", function () {
        debugger;
        var popup = $("#winSure").data("kendoWindow");
        popup.center().open();
    });
</script>




Мой Вам Просмотра Действий :
public ActionResult Documents()
        {
            var userName = User.Identity.Name;
            var user = dbContext.AspNetUsers.Where(usr => usr.UserName.Equals(userName)).FirstOrDefault();
            var Partner = dbContext.KenPartners.Where(k => k.UserId.Equals(user.Id)).FirstOrDefault();
            Session["PartnerId"] = Partner.PartnerId;
            Session["Uid"] = user.Id;
            string AppType = Session["ApplicationType"].ToString().Trim();
            DocumentViewModels objDocumentViewModels = new DocumentViewModels();
            int id = (int)Session["ApplicationId"];
            var DropData = new List<companylists>();
            var DropDataParent = new List<groupnamelists>();
            var DropDataChild = new List<documentslists>();

            if (AppType == "Individual")
            {


                DropData = (from x in dbContext.SysDocuments
                            where x.DocumentFor == "Individual"
                            select new CompanyLists
                            {
                                DocumentId = x.DocumentId,
                                DocumentName = x.DocumentName,
                                DocumentFor = x.DocumentFor,
                                GroupName = x.GroupName,
                                ApplicationId = id
                            }).ToList();
                ViewBag.DropData = DropData;
            }
            if (AppType == "Company")
            {
                DropData = (from x in dbContext.SysDocuments
                            where x.DocumentFor == "Company"
                            select new CompanyLists
                            {
                                DocumentId = x.DocumentId,
                                DocumentName = x.DocumentName,
                                DocumentFor = x.DocumentFor,
                                ApplicationId = id
                            }).ToList();
                ViewBag.DropData = DropData;
            }


            return PartialView("Documents", objDocumentViewModels);
        }

0 Ответов