Skip to content

Commit

Permalink
Getting images to work in AutoComplete box
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed Sep 12, 2013
1 parent a5c5d9c commit b793f2f
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 23 deletions.
19 changes: 8 additions & 11 deletions FrontDeskSolution/FrontDesk.Web/Controllers/ClientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ public IEnumerable<ClientViewModel> Get()
{
return new ClientViewModel[] {
new ClientViewModel() {
//ClientId= Guid.Empty,
Name="Steve Smith"
//Patients = new List<PatientViewModel>()
//{
// //new PatientViewModel()
// //{
// // Name="Darwin",
// // PatientId=Guid.Empty,
// // PhotoUrl="darwin.jpg"
// //}
//}
Name="Steve Smith",
Patients = new List<PatientViewModel>()
{
new PatientViewModel()
{
Name="Darwin"
}
}
},
new ClientViewModel() { Name="Julie" }
};
Expand Down
2 changes: 2 additions & 0 deletions FrontDeskSolution/FrontDesk.Web/FrontDesk.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Images\Clients\" />
<Folder Include="Images\Patients\" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ public ClientViewModel()
}
public Guid ClientId { get; set; }
public string Name { get; set; }
// public List<PatientViewModel> Patients { get; set; }
public List<PatientViewModel> Patients { get; set; }
}

public class PatientViewModel
{
public PatientViewModel()
{
PatientId = Guid.NewGuid();
}
public Guid PatientId { get; set; }
public String Name { get; set; }
public string PhotoUrl { get; set; }
}
}
29 changes: 20 additions & 9 deletions FrontDeskSolution/FrontDesk.Web/Views/Appointment/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<div class="editor-label">
Appointment For (choose client)
</div>
@* <div class="editor-field">*@
<div class="k-content">
<input type="text" id="client" />
<input type="text" id="client" style="width: 400px;" />
<p>Start typing to find a client</p>
<input type="button" value="Search" />
<input type="button" value="Select" />
<input type="button" value="Add New" />
</div>
<div class="editor-label">
Patient / Pet Name
Expand Down Expand Up @@ -72,12 +72,22 @@
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")

<script id="template" type="text/x-kendo-template">
<h3>${data.Name}</h3>
<img src="/Images/Clients/Steve_Smith.jpg" alt="${data.Name}" />
<span>${data.Name}</span><br />
#= renderPatientTemplate(data) #
</script>
<script id="patient-template" type="text/x-kendo-template">
# $.each(data.Patients, function (index, item) {
# <img src="/Images/Patients/darwin.jpg" alt="${item}" style="max-height:50px" /> #
});
#
</script>

<script type="text/javascript">
$(document).ready(function () {
var clients2 = new kendo.data.DataSource({
var clients = new kendo.data.DataSource({
type: "json",
transport: {
read: {
Expand All @@ -87,19 +97,20 @@
}
});
var clients = [{ "ClientId": "000-000", "Name": "Steve" }, { "ClientId": "000-001", "Name": "Julie" }];
$("#client").kendoAutoComplete({
minLength: 1,
filter: "contains",
placeholder: "Type client name...",
dataTextField: "Name",
dataValueField: "ClientId",
template: kendo.template($("#template").html()),
dataSource: clients2,
height: 370,
dataSource: clients,
}).data("kendoAutoComplete");
});
function renderPatientTemplate(data) {
return kendo.Template.compile($('#patient-template').html())(data);
}
</script>
<style scoped>
.demo-section {
Expand Down
3 changes: 2 additions & 1 deletion FrontDeskSolution/FrontDesk.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@

@* @Scripts.Render("~/bundles/jquery")*@
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>@* <script type="text/javascript" src="/Scripts/kendo.all.min.js"></script>*@
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
@* <script type="text/javascript" src="/Scripts/kendo.all.min.js"></script>*@
@RenderSection("scripts", required: false)
</body>
</html>

0 comments on commit b793f2f

Please sign in to comment.