I've tried replicating the example code from the Autocomplete demo page, but for some reason the GetOccupations function in the controller is never called, nor can I see that the onAdditionalData function in the cshtml is ever called either. The dropdown control is produced on the page, but it contains no contents. I have created as valid ModelView. Please help me identify the disconnect that I am having here. Thanks!
Index.cshtml:
@model IEnumerable<HanleighEnrollment.Global.Models.CaseOccupation>
@using Kendo.Mvc.UI
@{
/**/
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<div class="demo-section k-content">
@*<div class="control-label col-md-4">*@
<h4>Select an Occupation</h4>
@(Html.Kendo().AutoComplete()
.Name("occupations")
.DataTextField("Occupation")
.Filter("contains")
.MinLength(3)
.HtmlAttributes(new { style = "width:50%" })
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetOccupations", "Test")
.Data("onAdditionalData");
})
.ServerFiltering(true);
})
)
<div class="demo-hint">Hint: type "war"</div>
</div>
<script>
function onAdditionalData()
{
return
{
text: $("#occupations").val()
};
}
</script>
function onAdditionalData()
{
return
{
text: $("#occupations").val()
};
}
</script>
TestController.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using HanleighEnrollment.Global.Data;
using HanleighEnrollment.Global.Models;
namespace HanleighEnrollment.Admin.Controllers
{
public class TestController : Controller
{
private EfDbService db = new EfDbService();
// GET: TestController
public ActionResult Index()
{
return View(db.CaseOccupations.AsEnumerable());
}
public JsonResult GetOccupations(string text, int caseId)
{
var occupations = db.CaseOccupations.Select(occupation => new Global.Models.ViewModels.CaseOccupationViewModel
{
OccupationId = occupation.OccupationId,
CaseId = occupation.CaseId,
Occupation = occupation.Occupation,
JobDuties = occupation.JobDuties
});
if (!string.IsNullOrEmpty(text))
{
occupations = occupations.Where(p => p.CaseId == caseId && p.Occupation.Contains(text));
}
return Json(occupations, JsonRequestBehavior.AllowGet);
}
}
}
I am currently developing a mobile-first page using a listview with a template of k-card-list so it looks good on a phone(vertical). I would like to display the same info horizontally(almost like a grid) if the user is on a smaller device.
There is a ton of real estate wasted on a large screen that I would like to take advantage of.
What is the preferred method of doing this?
I have attached a couple of screenshots.
Below is my current template:
<script type="text/x-kendo-tmpl" id="template">
<div class="k-card-list">
<div class="k-card" style="min-width: 300px;">
<div class="k-card-header">
<div><h4>Service Date: #= kendo.toString(kendo.parseDate(ServiceDate), "MM/dd/yyyy")#</h4></div>
<div><h4>Store No: #:StoreNumber#</h4></div>
<div><h4>Store Name: #:StoreName#</h4></div>
<div><h4>Visit Type: #:VisitTypeName#</h4></div>
</div>
<div class="k-card-body">
<div>Round Trip Miles: ${ ActualTotalMileage == null ? '' : ActualTotalMileage }</div>
<div>Compensable Miles: ${ ActualCompensableMileage == null ? '' : ActualCompensableMileage }</div>
<div>Hours: ${ ActualHours == null ? '' : ActualHours }</div>
<div>Minutes: ${ ActualMinutes == null ? '' : ActualMinutes }</div>
<div>Comments: ${ CommentText == null ? '' : CommentText }</div>
</div>
<div class="k-card-actions k-card-actions-stretched">
<span class="k-card-action">
<span class="k-button k-flat k-primary k-edit-button">
# var miles = ActualTotalMileage#
# if (miles > 0) { #
Update Expense Claim
# } else { #
Create Expense Claim
#} #
</span>
</span>
</div>
</div>
<hr class="k-hr" />
</div>
</script>
Hello,
I used kendo upload widget in my project MVC project. How to pass the files through ajax to MVC method without submitting the form? I tried couple of ways but failed to get the files. Could someone help? Please see my sample code below:
---------In .cshtml file -----------
<div >
@(Html.Kendo().Upload()
.Name("files")
.Multiple(false)
.HtmlAttributes(new { aria_label = "files" })
.Validation(validation => validation.AllowedExtensions(new string[] {".xlsx" }))
)
@(Html.Kendo().Button()
.Name("UploadFile")
.Content("Process Files")
.Events(event => event.Click("onUploadFile "))
)
</div>
------In . js file:-------
Function onUploadFile(){
var upload = $("#files").data("kendoUpload"),
files = upload.getFiles();
$.post("TestMethod" ,
{ files: files }, <-----------------------------------I try to pass parameter here.
function (data, status) {...}
);
}
------In server side:-------
public JsonResult TestMethod (IEnumerable<HttpPostedFileBase> files)
{ ....
return Json(null, JsonRequestBehavior.AllowGet);
}
HI
I have a question about DateTimePicker.
When the inputed time is 11:15, then dropdown the time list,
Why the DateTimePicker do not scroll to the nearest time automatically ?
Maybe there have the same problem of TimePicker too.
See attachment.
Best regards
Chris
Need to filter cards in a blade(div) based on the value inside the card. Needed this for ASP.NET MVC.
For example, if we have many cards, base on the value inside the cards, need to filter or sort. Please let know whether is it possible and is there any demo available for that?
I have a grid with several foreign key columns which display combo-box editor templates. The user enters and selects an item, which sets the id on that column for that record in the grid.
If the user unfocuses the cell without selecting an option, the built-in validation message (shown in the attached screenshot) 'X must be a number' appears. This occurs when the input does not load any data (i.e. they type a name that doesn't exist in the database and so auto-complete doesn't find anything). It seems the validation skips the 'required' message and goes to this invalid-type message. We would like to change or bypass this so that the user doesn't see this user-unfriendly message.
Is there a way to (1) somehow force the combo-box to select an option when losing focus in this case where there was no valid auto-complete option (since normally it does auto-select said option), or (2) to somehow override this error message?
When you hover over the legend it displays all the points for the series you are hovering over. See attached image. Is there a way to turn this off?
<
div
>
<
div
id
=
"chart"
>
@(Html.Kendo().Chart<
CashInvestedAreaChart
>()
.Name("chartCashInvested")
.DataSource(ds => ds.Read(read => read.Action("CashInvestedChartData", "PracticeAnalytics")))
.Transitions(false)
.Theme("bootstrap")
.Legend(l => l.Visible(true)
.Position(ChartLegendPosition.Bottom))
.ChartArea(c => c.Margin(10, 8, 0, 10).Background("transparent").Height(280))
.SeriesDefaults(s => s
.Area()
.Line(l => l.Style(ChartAreaStyle.Smooth))
.Stack(false))
.CategoryAxis(axis => axis
.Categories(m => m.Date)
.Line(l => l.Visible(false))
.Labels(l => l.Visible(false))
.MajorGridLines(l => l.Visible(false))
)
.Tooltip(t => t.Visible(true).Template("#= series.name # <
br
/> #= kendo.toString(kendo.parseDate(category), 'MM/dd/yyyy') #: #= kendo.format('{0:C}', value) #"))
.Series(series =>
{
series.Area(model => model.MarketValue).Name("Market Value").Color("#60A7F5").Opacity(1);
series.Area(model => model.CashInvested).Name("Cash Invested").Color("#35608F").Opacity(1);
})
.ValueAxis(axis => axis
.Numeric()
.Labels(labels => labels.Template("#= ciFormatMillions(value) #" ) )
.AxisCrossingValue(-10)
.Line(line => line.Visible(false))
)
.Events(e => e.Render("scaleChart"))
)
</
div
>
$scope.dateFilter = {
extra:
true
,
operators: {},
ui:
function
(element) {
var
parent = element.parent();
while
(parent.children().length > 1)
$(parent.children()[0]).remove();
parent.prepend(
"Start Date:<br/><span class=\"k-widget k-datepicker k-header\">"
+
"<span class=\"k-picker-wrap k-state-default\">"
+
"<input data-bind=\"value: filters[0].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\""
+
" style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" aria-disabled=\"false\" "
+
" aria-readonly=\"false\" aria-label=\"Choose a date\">"
+
"<span unselectable=\"on\" class=\"k-select\" role=\"button\">"
+
"<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>"
+
"<br/>End Date:<br/>"
+
"<span class=\"k-widget k-datepicker k-header\"><span class=\"k-picker-wrap k-state-default\">"
+
"<input data-bind=\"value: filters[1].value\" class=\"k-input\" type=\"text\" data-role=\"datepicker\""
+
" style=\"width: 100%\" role=\"textbox\" aria-haspopup=\"true\" aria-expanded=\"false\" "
+
" aria-disabled=\"false\" aria-readonly=\"false\" aria-label=\"Choose a date\">"
+
"<span unselectable=\"on\" class=\"k-select\" role=\"button\">"
+
"<span unselectable=\"on\" class=\"k-icon k-i-calendar\">select</span></span></span></span>"
);
}
};
Hi,
I have an editor grid that has one editable cell. I want that cell to always be the input box (numeric text box in this case) instead of going back to a regular dirty cell after clicking out. So basically always keeping cells in edit mode.How can I achieve this? See attached image for example of what I mean.