or
@model HopitelNetworksPlatform.Models.FacilityProblem@{ ViewBag.Title = "ProblemTracking";}<h2>Problem Tracking<br />Facility: @Model.FacilityName</h2><p> @Html.ActionLink("Add Problem", "CreateProblem", new { facilityID = Model.FacilityID } )</p><div id="test"></div><div id="problemGrid"></div><script type="text/javascript"> var gridLoaded = false; var categoryData = new kendo.data.DataSource({ schema: { model: { id: "ProblemCategoryID", fields: { ProblemCategoryID: { type: "int" }, ProblemCategoryName: { type: "string" } } } }, transport: { read: { url: "@Url.Action("ProblemCategoryList", "Diagnostic")", type: "POST" } } }); categoryData.read(); var bedData = new kendo.data.DataSource({ schema: { model: { id: "RoomBedID", fields: { RoomBedID: { type: "int" }, RoomBedName: { type: "string" } } } }, transport: { read: { url: "@Url.Action("RoomBedList", "Facility", new { facilityID = Model.FacilityID })", type: "POST" } }, change: function(e) { if(gridLoaded == false) { DisplayGrid(); gridLoaded = true; } } }); bedData.read(); function lookupCategoryName(ProblemCategoryID) { if(ProblemCategoryID == undefined) { return ""; } else { var problemCategory = categoryData.get(ProblemCategoryID); return problemCategory.ProblemCategoryName; } } function lookupBedName(RoomBedID) { if(bedData.total() == 0) { return RoomBedID.toString(); //(todo)(change to unknown or something) } else { if(RoomBedID == undefined) { return ""; } else { var roomBed = bedData.get(RoomBedID); return roomBed.RoomBedName; } } } function DisplayGrid() { $("#problemGrid").kendoGrid({ pageable: true, columns: [ { field: "RoomBedID", title: "Location", width: "5%", editor: function(container,options) { $('<input name="' + options.field + '"/>').appendTo(container).kendoDropDownList({ dataSource: bedData, dataValueField: "RoomBedID", dataTextField: "RoomBedName", autobind: false }); }, template: "#= lookupBedName(RoomBedID) #" }, { field: "DateReported", title: "Date Reported" }, { field: "ProblemCategoryID", title: "Problem Type", editor: function(container,options) { $('<input name="' + options.field + '"/>').appendTo(container).kendoDropDownList({ dataSource: categoryData, dataValueField: "ProblemCategoryID", dataTextField: "ProblemCategoryName", autobind: false }); }, template: "#= lookupCategoryName(ProblemCategoryID) #" }, { field: "ProblemDescription", title: "Problem Description" , width: "30%" }, { field: "DateResolved", title: "Date Resolved" }, { field: "ResolutionDescription", title: "Resolution", width: "30%" }, { command: "edit", title: "Edit", width: "110px" } ], editable: "popup", toolbar: ["create", "save", "cancel"], dataSource: { schema: { model: { id: "ProblemID", fields: { ProblemID: { type: "int", editable: false, nullable: true }, RoomBedID: { type: "int", nullable: true }, RoomBedName: { type: "string" }, DateReported: { type: "date", editable: false }, ProblemCategoryID: { type: "int", nullable: true }, ProblemCategory: { type: "string" }, ProblemDescription: { type: "string" }, DateResolved: { type: "date", nullable: true, editable: false }, ResolutionDescription: { type: "string", nullable: true } } } }, batch: true, pageSize: 10, transport: { create: { url: "@Url.Action("CreateProblem2", "Diagnostic")", type: "POST" }, read: { url: "@Url.Action("ProblemList", "Diagnostic", new { facilityID = Model.FacilityID })", type: "POST" }, update: { url:"@Url.Action("UpdateProblem", "Diagnostic")", type: "POST" }, destroy: { url: "@Url.Action("DestroyProblem", "Diagnostic")", type: "POST" } } } });}</script><div data-role="view" data-title="Mobile" id="listmessages" data-init="listMessagesInit"> <h2>Customer Messages</h2> <p><?php echo $unread_messages . ' - unread messages'; ?></p> <ul id="message_list"></ul> </div> <script id="message_list_template" type="text/x-kendo-template"><a href=""><div style="float:left; width:150px; height: 50px" class="isnew_#= isnew #">#= customer_name #<br />#= created #</div><div style="height: 50px"id="message_#= id #" class="isnew_#= isnew #">#= message #</div></a></script> <script> function listMessagesInit(){ var dataSource = new kendo.data.DataSource({ transport: { read: "/messages/data", dataType: "json", update: { url: function() { //where id is a global variable var url = "/messages/markasread/" + id + "/" + read; return url; }, type: "POST", dataType: "json" //other configurations }, destroy: { url: function() { //where id is a global variable var delurl = "/messages/delete/" + id; return delurl; }, type: "DELETE", dataType: "json" } }, schema: { model: { id: "id", fields: { created: { type: "string" }, message: { type: "string" }, customer_name: { type: "string" }, isnew: { type: "string" } } } } }); $("#message_list").kendoMobileListView({ dataSource: dataSource, //pullToRefresh: true, //appendOnRefresh: true, style: "inset", click: function(e) { var id = e.dataItem.id; var selected = dataSource.get(id); window.kendoMobileApplication.navigate("/messages/view/" + id); }, template: $("#message_list_template").text() }); } </script> <style> #listmessages div.isnew_1 {font-weight:bold} #listmessages div.isnew_0 {font-weight:normal} </style> <div data-role="view" data-title="Mobile" id="viewmessage" data-init="viewMessageInit"> <h2>Message</h2> <p>Date: <?=$message->message->created?></p> <p>From: <?=$message->message->customer_name?></p> <p>Email: <a href="mailto:<?=$message->message->email?>" target="_blank"><?=$message->message->email?></a></p> <p>Telephone: <?=$message->message->customer_telephone?></p> <p>Location IP:<?=$message->message->ip?></p> <div data-role="scroller"> <p><?=$message->message->message?></p> </div> <?php $read_text = ($message->message->isnew == 1 ? 'Mark as read' : 'Mark as unread'); ?> <?php $read = ($message->message->isnew == 1 ? 0 : 1); ?> <p><a data-align="left" data-role="button" id="markasread" ><?=$read_text?></a> <a data-align="right" data-role="button" id="delete">Delete</a></p> </div> <script> function viewMessageInit(){ //var selected is defined in previous view - how to access this? $("#markasread").click(function(){ selected.set("isnew", read); dataSource.sync(); }); $("#delete").click(function(){ dataSource.remove(selected); dataSource.sync(); }); } </script>return "<span class='incomplete'>InComplete</span>";<span class='incomplete'>InComplete</span>