Html.Kendo().Grid<MedSouth.Models.LinkedFilesModel>()
.Name("LinkedFilesGrid#=PkPacketID#")
.Sortable()
.Scrollable()
.Filterable()
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkLinkedFilesID).Width(130).Hidden(true);
columns.Bound(e => e.FkPacketID).Width(130).Hidden(true);
columns.Bound(e => e.FileName)
.Width(100)
.Title("Download File")
.Sortable(false)
.Filterable(false)
//.ClientTemplate((@Html.ActionLink("Download File", "Download", "LinkedFiles", new { ID = "#=PkLinkedFilesID#" }, null).ToHtmlString()))
;
columns.Bound(e => e.FileName).Width(130);
columns.Bound(e => e.FileDescription).Width(175).Title("Description");
//columns.Bound(e => e.FileURL).Width(300);
})
.ToolBar(tb =>
{
tb.Template(@<text>
<div >
<a class="k-button" href="\\#" onclick="return toolbar_click()">Add File</a>
</div>
</text>);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkLinkedFilesID))
.Read(read => read.Action("LinkedFiles_Read", "LinkedFiles", new { FkPacketID = "#=PkPacketID#" }))
// .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles"))
.Update(update => update.Action("LinkedFiles_UpdateWithReplace", "LinkedFiles"))
.Destroy(destroy => destroy.Action("LinkedFiles_Destroy", "LinkedFiles"))
.Create(create => create.Action("LinkedFiles_Create", "LinkedFiles", new { PkPacketID = "#=PkPacketID#" }))
)
.ToClientTemplate()
);Here is the Javascript associated with the button. It opens an aspx page in containing a file upload control - <input name="files" id="files" type="file" runat="server" />. This allows the user to select a file and save information to the database. This data will then be displayed in the LinkedFiles grid defined above.<script type="text/javascript"> function toolbar_click() {
console.log("Toolbar command is clicked!");
ShowReport();
return false;
} function ShowReport(e) { var grid = $("#LinkedFilesGrid").data("kendoGrid");
var dataItem = grid.dataItem($(e.currentTarget).closest("tr"));
alert(e); var id = dataItem.FkPacketID;
var u = "/Test.aspx?ID=" + id;
alert(u);
kendoWindow = $("#window2").data("kendoWindow");
kendoWindow.refresh({ url: u });
kendoWindow.center();
kendoWindow.open();
}</script>In a test application, this all works fine, apart from having to hard-code the PkPacketID in the Javascript function, where the variable "id" is hard-coded.When the parent grid detail is opened, the grid sees the ID defined in the grid name - "LinkedFilesGrid#=PkPacketID#" correctly and attempts to populate the grid with matching records.Currently there are no records available to load into this grid, so step one is to click the "Add File" button, which needs to find and pass the PkPacketID to the aspx page.This is the first issue: I cannot find that ID. Tha Javascript in "ShowReport" errors with "Cannot read property 'dataItem' of null" - it is not seeing the grid containing the "Add File" button, whether the grid contains data or not.Question: How do I get the PkPacketID that is defined in the grid name?
Thanks for your help.
Stephen
5 Answers, 1 is accepted
You can get the parent model ID by simply passing it to the "toolbar_click" function inside the child Grid toolbar as follows:
<
a
class
=
"k-button"
href
=
"\\#"
onclick
=
"return toolbar_click(#=PkPacketID#)"
>Add File</
a
>
Regards,
Vladimir Iliev
Telerik
See What's Next in App Development. Register for TelerikNEXT.
Vladimir,
Thanks for your reply and my apologies for not getting back with you sooner. I am currently involved on some other projects and have not had a chance to try your suggestions. As soon as I can, I will look into this sagaina dn let you know the outcome.
Thanks
Stephen
Hello Stephen,
Thank you the update. Let us know if the issue is resolved.
Have a great day!
Regards,Dimiter Madjarov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
I have tried the suggestions but to no avail; I still get the same error.
Following is the full cshtml code - hopefully someone has another idea?
Thanks
@{
ViewBag.Title = "PacketsForRequestsGrid";
}
<h2 style="color:#717DBC">Requests</h2>
<button id="save">Save state</button>
<button id="load">Load state</button>
@model MedSouth.Models.GridStateModel
@Html.Kendo().DropDownListFor(m => m.UserID).OptionLabel("--Select One--").DataTextField("StateDescription").DataValueField("PkGridStateID").DataSource(dataSource =>
{
dataSource.Read(read =>
{
read.Action("GetGridStateTemplates", "GridState");
}).ServerFiltering(true);
}).HtmlAttributes(new { style = "width:250px" })
<div class="float-left">
@(Html.Kendo().Grid<MedSouth.Models.PacketsModel>()
.Name("PacketsForRequestsGrid")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
columns.Bound(e => e.PkPacketID).Width(140).Hidden(true);
columns.Bound(e => e.PkInvoiceID).Width(140).Hidden(true);
//columns.Bound(e => e.FkFacilityID).Width(70).Title("Facility ID");
columns.Bound(e => e.InvoiceNumber).Width(100).Title("REQ ID");//.HtmlAttributes(new { style = "text-align: right" });
columns.Bound(e => e.BillingCompanyName).Width(100).Title("Company Name");
columns.Bound(e => e.FkPatientID).Width(70).Title("Pat ID").Visible(false);
columns.Bound(e => e.FKStatusID).Width(70).Title("Status ID").Visible(false);
//columns.Bound(e => e).Width(70).Title("Status ID").Visible(false);
columns.Bound(e => e.LocationCode).Width(80).Title("Clinic ID");
columns.Bound(e => e.PatientName).Width(100).Title("Patient Name");
columns.Bound(e => e.PatientSocialSecurityNumber).Width(100).Title("SSN");
columns.Bound(e => e.StatusName).Width(100).Title("Status");
columns.Bound(e => e.MRNumber).Width(70).Title("MR#");
columns.Bound(e => e.RefNumber).Width(70).Title("Ref#");
columns.Bound(e => e.ReceivedDate).Width(70).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PrepayReadyDate).Width(70).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PendingDate).Width(70).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PrepayRecordSentDate).Width(80).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PendingReadyDate).Width(80).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.CompletionDate).Width(70).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.FkPatientID).Width(70).Title("Patient ID");
//columns.Bound(e => e.PatientFirstName).Width(140);
//columns.Bound(e => e.PatientLastName).Width(140);
//columns.Bound(e => e.PatientLastName).Width(100).Title("Last Name");
//columns.Bound(e => e.PatientBillingStreetAddress).Width(100).Title("Billing Address");
//columns.Bound(e => e.PatientBillingState).Width(100).Title("Billing State");
//columns.Bound(e => e.PatientBillingZipCode).Width(70).Title("Zip");
columns.Command(command => command.Custom("Print Invoice").Click("ShowReport")).Width(125);
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("PacketsRequestsForm").Window(w => w.Title("Requests Add/Edit").Name("editWindow").Width(900).Height(800)))
.HtmlAttributes(new { style = "height: 700px; width: 98%;"})
.Scrollable()
.ClientDetailTemplateId("template")
.Groupable()
.Sortable()
//Extra Features
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.ColumnMenu()
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.Filterable(filtering => filtering
.Enabled(true))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Model(model => model.Id(e => e.PkPacketID))
.Read(read => read.Action("PacketsForRequests_ReadByUserID", "PacketsForRequests"))
.Create(create => create.Action("PacketsForRequests_Create", "PacketsForRequests"))
.Destroy(destroy => destroy.Action("PacketsForRequests_Destroy", "PacketsForRequests"))
.Update(update => update.Action("PacketsForRequests_UpdateWithReplace", "PacketsForRequests"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
)
@(Html.Kendo().Window()
.Name("window")
.Title("Print Report")
.Content("Loading report data...")
.Draggable()
.Resizable()
.Width(865)
.Height(825)
.Visible(false)
)
@(Html.Kendo().Window()
.Name("window2")
.Title("Link Files to Request")
.Content("Loading interface...")
.Draggable()
.Resizable()
.Width(600)
.Height(250)
.Visible(false)
)
<script id="template" type="text/kendo-tmpl">
@( Html.Kendo().TabStrip()
.Name("tabStrip_#=PkPacketID#")
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text("Charges").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.ChargesModel>()
.Name("ChargesGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkInvoiceID).Width(140).Hidden(true);
//columns.Bound(e => e.InvoiceNumber).Width(80);
columns.Bound(e => e.InvoiceDate).Width(140).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.OtherPages).Width(80);
columns.Bound(e => e.QtyOrders).Width(80);
columns.Bound(e => e.OtherPages).Width(80);
columns.Bound(e => e.PhotocopyCharge).Width(80);
columns.Bound(e => e.ProcessingCharge).Width(80);
columns.Bound(e => e.ProcessingFee).Width(80);
columns.Bound(e => e.RetrievalFee).Width(80);
columns.Bound(e => e.ShippingHandlingFee).Width(80);
columns.Bound(e => e.CertificationCharge).Width(80);
columns.Bound(e => e.NotaryCharge).Width(80);
//columns.Bound(e => e.BillingCompanyName).Width(180).Title("Company Name");
//columns.Bound(e => e.BillingAddress1).Width(140).Title("Address 1");
//columns.Bound(e => e.BillingAddress2).Width(140).Title("Address 2");
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChargesForm").Window(w => w.Title("Charges Add/Edit").Name("editWindow").Width(1050).Height(600)))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkInvoiceID))
.Read(read => read.Action("Charges_ReadByID", "Charges", new { FkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("Charges_Create", "Charges", new { PkPacketID = "#=PkPacketID#" }))
.Update(read => read.Action("Charges_UpdateWithReplace", "Charges", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(read => read.Action("Charges_Destroy", "Charges"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Pageable()
.Sortable()
.Scrollable()
.ToClientTemplate()
);
items.Add().Text("Payments").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.PaymentsModel>()
.Name("PaymentsGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(120);
columns.Bound(e => e.PkPaymentID).Width(80).Hidden(true);
columns.Bound(e => e.CheckNumber).Width(80);
columns.Bound(e => e.DepositNumber).Width(80);
//columns.Bound(e => e.PrintType).Width(80);
columns.Bound(e => e.PaymentDate).Width(140).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.Payment).Width(140);
columns.Bound(e => e.Details).Width(280);
//AccountNumber
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("PaymentsForm").Window(w => w.Title("Payments Add/Edit").Name("editWindow").Width(550).Height(500)))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkPaymentID))
.Read(read => read.Action("Payments_ReadByID", "Payments", new { FkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("Payments_Create", "Payments", new { PkPacketID = "#=PkPacketID#" }))
.Update(read => read.Action("Payments_UpdateWithReplace", "Payments", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(read => read.Action("Payments_Destroy", "Payments"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Pageable()
.Sortable()
.Scrollable()
.ToClientTemplate()
);
items.Add().Text("Requestor").Content(//obj =>
obj =>
Html.Kendo().Grid<MedSouth.Models.RequestorsModel>()
//"<div class='requestorDetail'>" +
// "<ul>" +
// "<li><label>#=BillingCompanyName</label></li>" +
// "</ul>" +
//"</div>"
.Name("RequestorGrid_#=FkRequestorID#")
.Columns(columns =>
{
columns.Bound(e => e.PkRequestorID).Width(140).Hidden(true);
columns.Bound(e => e.BillingCompanyName).Width(180).Title("Company Name");
columns.Bound(e => e.BillingAddress1).Width(140).Title("Address 1");
columns.Bound(e => e.BillingAddress2).Width(140).Title("Address 2");
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkRequestorID))
.Read(read => read.Action("Requestors_ReadByID", "Requestors", new { FkRequestorID = "#=FkRequestorID#" }))
)
.ToClientTemplate()
);
items.Add().Text("Chart").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.ChartModel>()
.Name("ChartsGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(120);
columns.Bound(e => e.PkPacketContentID).Width(130).Hidden(true);
columns.Bound(e => e.PacketContentType).Width(180);
columns.Bound(e => e.StartDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.EndDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.Comments).Width(600);
//columns.Bound(e => e.AccountNumber).Width(140);
//AccountNumber
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkPacketContentID))
.Read(read => read.Action("Charts_ReadByID", "Charts", new { FkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("Charts_Create", "Charts", new { PkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("Charts_UpdateWithReplace", "Charts", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(destroy => destroy.Action("Charts_Destroy", "Charts"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(850).Height(300)))
.Pageable()
.Sortable()
.Scrollable()
.ToClientTemplate()
);
items.Add().Text("Date History").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.DateHistoryModel>()
.Name("DatHistoryGrid#=PkPacketID#")
.Columns(columns =>
{
//columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkPacketID).Width(130).Hidden(true);
columns.Bound(e => e.ReceivedDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PendingDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PendingReadyDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PrePayReadyDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.PrePayRecordSentDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.CompletionDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.AccountNumber).Width(140);
//AccountNumber
})
//.ToolBar(toolbar =>
//{
// toolbar.Create();
//})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkPacketID))
.Read(read => read.Action("DateHistory_ReadByID", "DateHistory", new { PkPacketID = "#=PkPacketID#" }))
//.Create(create => create.Action("Charts_Create", "Charts", new { PkPacketID = "#=PkPacketID#" }))
//.Update(update => update.Action("Charts_UpdateWithReplace", "Charts"))
//.Destroy(destroy => destroy.Action("Charts_Destroy", "Charts"))
)
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(1200).Height(800)))
.ToClientTemplate()
);
items.Add().Text("Notes").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.NotesModel>()
.Name("NotesGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(120);
columns.Bound(e => e.PKNoteID).Width(140).Hidden(true);
columns.Bound(e => e.NoteDate).Width(60).Title("Note Date").Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.Employee).Width(60).Title("Employee");
columns.Bound(e => e.Notes).Width(320).Title("Notes");
//columns.Bound(e => e.BillingAddress2).Width(140).Title("Address 2");
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("NotesForm").Window(w => w.Title("Notes Edit").Name("editWindow").Width(800).Height(350)))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PKNoteID))
.Read(read => read.Action("Notes_ReadByID", "Notes", new { PkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("Notes_UpdateWithReplace", "Notes"))
.Create(create => create.Action("Notes_Create", "Notes", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(destroy => destroy.Action("Notes_Destroy", "Notes"))
.Events(events => events.RequestEnd("onRequestEnd"))
)
.Pageable()
.Sortable()
.ToClientTemplate()
);
items.Add().Text("Postage").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.PostageModel>()
.Name("PostageGrid#=NumberOfPages#")
.Columns(columns =>
{
//columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkPostageID).Width(130).Hidden(true);
columns.Bound(e => e.SheetsofPaper).Width(130);
columns.Bound(e => e.EnvelopeSize).Width(130);
columns.Bound(e => e.Weight).Width(130);
columns.Bound(e => e.Postage).Width(130);
//columns.Bound(e => e.ReceivedDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.PendingDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.AccountNumber).Width(140);
//AuthorizationExpireDate
})
//.ToolBar(toolbar =>
//{
// toolbar.Create();
//})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkPostageID))
.Read(read => read.Action("Postage_Read", "Postage", new { NumberOfPages = "#=NumberOfPages#" }))
//.Create(create => create.Action("Charts_Create", "Charts", new { PkPacketID = "#=PkPacketID#" }))
//.Update(update => update.Action("Charts_UpdateWithReplace", "Charts"))
//.Destroy(destroy => destroy.Action("Charts_Destroy", "Charts"))
)
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(1200).Height(800)))
.ToClientTemplate()
);
items.Add().Text("Pending").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.PacketsPendingModel>()
.Name("PendingGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.FkPacketID).Width(130).Hidden(true);
columns.Bound(e => e.ReasonDescription).Width(130);
columns.Bound(e => e.Comments).Width(300);
//columns.Bound(e => e.PendingDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.AccountNumber).Width(140);
//AuthorizationExpireDate
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.FkPacketID))
.Read(read => read.Action("PacketsPending_Read", "PacketsPending", new { FkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("PacketsPending_Create", "PacketsPending", new { PkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("PacketsPending_UpdateWithReplace", "PacketsPending"))
.Destroy(destroy => destroy.Action("PacketsPending_Destroy", "PacketsPending"))
)
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("PendingForm").Window(w => w.Title("Pending Reason Add/Edit").Name("editWindow").Width(800).Height(350)))
.ToClientTemplate()
);
items.Add().Text("HIPAA").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.HippaReasonsModel>()
.Name("HipaaGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); }).Width(130);
columns.Bound(e => e.PkPacketID).Width(130).Hidden(true);
columns.Bound(e => e.PurposeOfDisclosure).Width(120);
columns.Bound(e => e.AuthorizationExpireEvent).Width(120);
columns.Bound(e => e.HIPAAStartDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.HIPAAEndDate).Width(60).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.AuthorizationExpireDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.ReceivedDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.PendingDate).Width(60).Format("{0:MM/dd/yyyy}");
//columns.Bound(e => e.AccountNumber).Width(140);
//AuthorizationExpireDate
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkPacketID))
.Read(read => read.Action("HippaReasons_ReadByID", "HippaReasons", new { PkPacketID = "#=PkPacketID#" }))
//.Create(create => create.Action("HippaReasons_CreateForPackets", "HippaReasons", new { PkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("HippaReasons_UpdateWithReplaceForPackets", "HippaReasons", new { PkPacketID = "#=PkPacketID#" }))
//.Destroy(destroy => destroy.Action("Charts_Destroy", "Charts"))
)
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("HIPAAFormForPackets").Window(w => w.Title("HIPAA Add/Edit").Name("editWindow").Width(1000).Height(600)))
.ToClientTemplate()
);
items.Add().Text("Linked Files").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.LinkedFilesModel>()
.Name("LinkedFilesGrid#=PkPacketID#")
.Sortable()
.Scrollable()
.Filterable()
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkLinkedFilesID).Width(130).Hidden(true);
columns.Bound(e => e.FkPacketID).Width(130).Hidden(true);
columns.Bound(e => e.FileName)
.Width(100)
.Title("Download File")
.Sortable(false)
.Filterable(false)
//.ClientTemplate((@Html.ActionLink("Download File", "Download", "LinkedFiles", new { ID = "#=PkLinkedFilesID#" }, null).ToHtmlString()))
;
columns.Bound(e => e.FileName).Width(130);
columns.Bound(e => e.FileDescription).Width(175).Title("Description");
//columns.Bound(e => e.FileURL).Width(300);
})
.ToolBar(tb =>
{
tb.Template(@<text>
<div >
<a class="k-button" href="\\#" onclick="return toolbar_click()">Add File</a>
</div>
</text>);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkLinkedFilesID))
.Read(read => read.Action("LinkedFiles_Read", "LinkedFiles", new { FkPacketID = "#=PkPacketID#" }))
// .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles"))
.Update(update => update.Action("LinkedFiles_UpdateWithReplace", "LinkedFiles"))
.Destroy(destroy => destroy.Action("LinkedFiles_Destroy", "LinkedFiles"))
.Create(create => create.Action("LinkedFiles_Create", "LinkedFiles", new { PkPacketID = "#=PkPacketID#" }))
)
.ToClientTemplate()
);
//items.Add().Text("Linked Files").LoadContentFrom("LinkedFiles", "LinkedFiles", new { ID = "#=PkPacketID#" });
items.Add().Text("Clinic").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.ClinicModel>()
.Name("ClinicGrid#=PkFacilityID#")
.Columns(columns =>
{
//columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkFacilityID).Width(130).Hidden(true);
columns.Bound(e => e.LocationCode).Width(120);
columns.Bound(e => e.FacilityName).Width(120);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkFacilityID))
.Read(read => read.Action("Clinics_ReadByID", "Clinic", new { PkFacilityID = "#=PkFacilityID#" }))
//.Create(create => create.Action("Charts_Create", "Charts", new { PkPacketID = "#=PkPacketID#" }))
//.Update(update => update.Action("Charts_UpdateWithReplace", "Charts"))
//.Destroy(destroy => destroy.Action("Charts_Destroy", "Charts"))
)
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(1200).Height(800)))
.ToClientTemplate()
);
items.Add().Text("Field").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.FieldCommModel>()
.Name("FieldCommGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkCommunicationID).Width(130).Hidden(true);
//columns.Bound(e => e.Author).Width(120).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.Author).Width(120);
columns.Bound(e => e.CommunicationReceived).Width(120);
columns.Bound(e => e.CommunicationOther).Width(120);
columns.Bound(e => e.CommunicationFrom).Width(120);
columns.Bound(e => e.CommunicationFromOther).Width(120);
columns.Bound(e => e.ContactName).Width(120);
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("FieldCommForm").Window(w => w.Title("Field Comm Add/Edit").Name("editWindow").Width(800).Height(850)))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkCommunicationID))
.Read(read => read.Action("FieldComm_ReadByID", "FieldComm", new { PkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("FieldComm_Create", "FieldComm", new { FkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("FieldComm_UpdateWithReplace", "FieldComm", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(destroy => destroy.Action("FieldComm_Destroy", "FieldComm"))
)
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(1200).Height(800)))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.ToClientTemplate()
);
items.Add().Text("CSAR").Content(obj =>
Html.Kendo().Grid<MedSouth.Models.CSARModel>()
.Name("CSARGrid#=PkPacketID#")
.Columns(columns =>
{
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
columns.Bound(e => e.PkActionReportID).Width(130).Hidden(true);
columns.Bound(e => e.ReportDate).Width(120).Format("{0:MM/dd/yyyy}");
columns.Bound(e => e.Contact).Width(120);
columns.Bound(e => e.OtherComments).Width(120);
columns.Bound(e => e.ActionTaken).Width(120);
})
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("CSARForm").Window(w => w.Title("CSAR Add/Edit").Name("editWindow").Width(1200).Height(800)))
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Model(model => model.Id(e => e.PkActionReportID))
.Read(read => read.Action("CSAR_ReadByID", "CSAR", new { PkPacketID = "#=PkPacketID#" }))
.Create(create => create.Action("CSAR_Create", "CSAR", new { PkPacketID = "#=PkPacketID#" }))
.Update(update => update.Action("CSAR_UpdateWithReplace", "CSAR", new { PkPacketID = "#=PkPacketID#" }))
.Destroy(destroy => destroy.Action("CSAR_Destroy", "CSAR"))
)
//.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ChartsForm").Window(w => w.Title("Charts Add/Edit").Name("editWindow").Width(1200).Height(800)))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.ToClientTemplate()
);
})
.ToClientTemplate()
)
</script>
</div>
<script type="text/javascript">
// function toolbar_click() {
// console.log("Toolbar command is clicked!");
// ShowLinkedFile();
// return false;
// }
// function ShowLinkedFile(e) {
// $("#window2").closest(".k-window").css({
// top: 50,
// left: 450
// });
// kendoWindow = $("#window2").data("kendoWindow");
// kendoWindow.refresh({ url: "/Test.aspx?ID=7" });
// //kendoWindow.center();
// kendoWindow.open();
// }
function dataBound() {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
function onRequestEnd(evt) {
if (evt.type === "update" || evt.type === "create") {
evt.sender.read();
}
}
function MyChangeEvent(e) {
var box = $("#PatientName").data("kendoComboBox");
var patient = $("#ModelPatient").data("kendoNumericTextBox");
//var index = this;
var tbox = $('#PatientSocialSecurityNumber');
if (this.text() != "") {
var dataItemSingle = box.dataItem(e.item.index());
var DOBDate = kendo.parseDate(dataItemSingle.DOB, "M/d/y");
var dpDOB = $('#DateOfBirth').data("kendoDatePicker");
var SSN = dataItemSingle.SSN;
dpDOB.value(kendo.toString(new Date(DOBDate), "d"));
dpDOB.trigger("change");
patient.value(this.value());
patient.trigger("change");
tbox.val(SSN);
tbox.trigger("change");
}
}
function ClinicEvent(e) {
var box = $("#LocationCode").data("kendoComboBox");
var clinic = $("#ModelClinic").data("kendoNumericTextBox");
var tbox = $('#Clinic');
var invoice = $('#InvoiceNumber');
var dt = new Date();
var dd = dt.getDate();
var mm = dt.getMonth()+1;
var yyyy = dt.getFullYear();
if (this.text() != "") {
var dataItemSingle = box.dataItem(e.item.index());
//var DOBDate = kendo.parseDate(dataItemSingle.DOB, "M/d/y");
//var dpDOB = $('#DateOfBirth').data("kendoDatePicker");
var FacilityName = dataItemSingle.FacilityName;
var LocationCode = dataItemSingle.LocationCode;
var invoiceNum = String(dataItemSingle.LocationCode) + String(mm) + String(dd) + String(yyyy);
//dpDOB.value(kendo.toString(new Date(DOBDate), "d"));
//dpDOB.trigger("change");
clinic.value(this.value());
clinic.trigger("change");
tbox.val(FacilityName);
tbox.trigger("change");
invoice.val(invoiceNum);
invoice.trigger("change");
}
}
</script>
<script type="text/javascript">
$("#save").click(function () {
var grid = $("#PacketsForRequestsGrid").data("kendoGrid");
var dataSource = grid.dataSource;
var state = {
columns: grid.columns,
page: dataSource.page(),
pageSize: dataSource.pageSize(),
sort: dataSource.sort(),
filter: dataSource.filter(),
group: dataSource.group()
};
$.ajax({
url: "/GridState/Save",
data: {
data: JSON.stringify(state), grid: "PacketsForRequestsGrid"
}
});
});
$("#load").click(function () {
var grid = $("#grid").data("kendoGrid");
var dataSource = grid.dataSource;
$.ajax({
url: "/Home/LoadTemplate",
data: {
data: JSON.stringify(1)
},
success: function (state) {
state = JSON.parse(state);
var options = grid.options;
options.columns = state.columns;
options.dataSource.page = state.page;
options.dataSource.pageSize = state.pageSize;
options.dataSource.sort = state.sort;
options.dataSource.filter = state.filter;
options.dataSource.group = state.group;
grid.destroy();
$("#grid")
.empty()
.kendoGrid(options);
}
});
});
</script>
<script type="text/javascript">
function toolbar_click() {
console.log("Toolbar command is clicked!");
ShowReport();
return false;
}
function ShowReport(e) {
var grid = $("#PacketsForRequestsGrid").data("kendoGrid");
var dataItem = grid.dataItem($(e.currentTarget).closest("tr"));
alert(e);
var id = dataItem.FkPacketID;
var u = "/Test.aspx?ID=" + id;
alert(u);
kendoWindow = $("#window2").data("kendoWindow");
kendoWindow.refresh({ url: u });
kendoWindow.center();
kendoWindow.open();
}
</script>
FYI: the fix was to pass the ID in from the button click:
<a class="k-button" href="\\#" onclick="return toolbar_click(#=PkPacketID#)">Add File</a>
Thank you
Stephen