在剑道UI Ajax的绑定文件的Ajax绑定描述传递多个数据参数为一个操作的方法,但它并没有解决通过阵列等多选值.
在下面的示例中,如果multisel设置为类似"237896"的字符串,则控制器接收sitesFilter ="237896".但如果multisel设置为MultiSelect值,如下所示,则控制器接收sitesFilter = null.
使用MVC包装器将所有MultiSelect值发送到Action方法的正确方法是什么?
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("Documents_Read", "Document")
.Type(HttpVerbs.Post)
.Data("getCriteria"))
function getCriteria() {
var multisel = $("#sites").data("kendoMultiSelect").value();
return {
sitesFilter: multisel
};
}
public ActionResult Documents_Read([DataSourceRequest] DataSourceRequest request, string sitesFilter=null)
{
return Json(GetDocuments(sitesFilter).ToDataSourceResult(request), JsonRequestBehavior.DenyGet);
}
Run Code Online (Sandbox Code Playgroud)
编辑:getCriteria应该将数据转换为字符串,如下所示:
function getCriteria() {
var multisel = $("#sites").data("kendoMultiSelect").value().toString();
return {
sitesFilter: multisel
};
Run Code Online (Sandbox Code Playgroud) 我是MVC框架和剑道的新手,所以你必须忍受我.这是我的图表基类(我正在使用的DatedChart类只是一个类型的图表<DateTime, double>:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Project.Models.Charts
{
public class NewChart<XType, YType> : IMailListener
where XType:IComparable
where YType:IComparable
{
public Dictionary<string, DataSeries<XType, YType>> SeriesList { get; protected set; }
public string Title { get; set; }
public string XLabel { get; set; }
public string YLabel { get; set; }
public NewChart(string title, string xLabel, string yLabel)
{
this.SeriesList = new Dictionary<string, DataSeries<XType, YType>>();
this.Title = title;
this.XLabel = xLabel;
this.YLabel = yLabel; …Run Code Online (Sandbox Code Playgroud) 在@(Html.Kendo().Grid(Model)中定义DataSource时,我已经成功使用了
.DataSource( dataSource => .Ajax( ).Model( model => model.Id( m => m.PROPERTY ) ) )
Run Code Online (Sandbox Code Playgroud)
其中PROPERTY是作为模型的对象的属性.如果Model是System.Data.DataTable并且DataTable中的Id列是TableId,那么定义Model.Id的正确语法是什么?
换句话说,model.Id(m => ???).
我试过了,model.Id( m => Model.PrimaryKey )这似乎满足了model.Id设置的要求,但Update Action(.Update(update => update.Action("MyUpdateMethod", "MyController"))没有命中,所以我认为仍然有问题.
我在我的MVC项目上使用kendo网格.问题是,错误消息无法在视图页面上显示.当我使用谷歌的开发人员工具跟踪JSON数据时,我可以看到错误数据是正确的:
{"Data":null,"Total":0,"AggregateResults":null,"Errors":["There is record(s) with same name.Please review your new records."]}
Run Code Online (Sandbox Code Playgroud)
Expection消息已传递给控制器上的结果参数.
控制器:
catch (Exception exp)
{
var result = exp.ToDataSourceResult(request);
// var result1 = ModelState.ToDataSourceResult();
// ModelState.AddModelError("UpdateAmbulance", exp.Message);
return Json(result, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
这是视图页面上的kendo网格代码:
<!-- Grid -->
@(Html.Kendo().Grid<AIS.UI.WebService.Proxy.DSrvAllService.AMBULANCEDEFINITIONS>() //Bind the grid to ViewBag.Products
.Name("grid")
// .BindTo(Model)
.Columns(columns =>
{
columns.Bound(product => product.DESCRIPTION).Title("<strong>Ambulance Description</strong>").Width("20%");
//.ClientTemplate("<strong>#:DESCRIPTION#</>strong");
columns.Bound(product => product.CODE).Title("<strong>Ambulance Description</strong>").Width("20%");
columns.Command(commands =>
{
commands.Destroy().HtmlAttributes(new { id = "buttondelete" ,style="display:none" });
}).Title("Operations").Width("10%");
})
.ToolBar(toolbar =>
{
toolbar.Create().HtmlAttributes(new { id="addbutton",style = "font-weight:bold;color:blue" }).Text("Add …Run Code Online (Sandbox Code Playgroud) 我有以下困境:
我正在尝试在局部视图内制作Kendo UI网格,该视图将与不同类型的对象一起使用,并且可以支持诸如Delete或Create之类的操作。
该对象如下所示:
public class GridViewModel
{
public Type ObjectType { get; set; }
public IEnumerable<object> Items { get; set; }
public GridViewModel(Type type, IEnumerable<object> items)
{
Items = items;
ObjectType = type;
}
}
Run Code Online (Sandbox Code Playgroud)
ObjectType是类型类型的变量,该变量保留类的类型。例如员工,产品,发票或其他任何东西。
Items是前面提到的类型的IEnumerable对象列表。
假设我们有一个Employee View,我们在以下内部调用:
@model IEnumerable<Employee>
@{
GridViewModel gridModel = new GridViewModel(typeof(Employee), Model);
}
@{
Html.RenderPartial("_AdvancedGrid", gridModel);
}
Run Code Online (Sandbox Code Playgroud)
这样,我们以指定对象作为模型加载局部视图。
现在,Kendo UI Grid在局部视图内:
@model XMLProject.Models.GridViewModel
@{
System.Reflection.PropertyInfo[] propertyArray = Model.ObjectType.GetProperties();
}
@(Html.Kendo().Grid<Employee>()
.Name("Grid")
.Columns(columns =>
{
foreach (var property in propertyArray)
{
columns.Bound(property.Name);
}
columns.Command(c …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个kendo调度程序,但你需要传入一个模型.在示例中,它告诉您使用
@(Html.Kendo().Scheduler <Kendo.Mvc.Examples.Models.Scheduler.TaskViewModel>())
但是我当然没有这个视图模型.有人可以在我找到的地方给我打电话吗?我一直在寻找超过5个小时.请帮忙
asp.net-mvc asp.net-mvc-4 kendo-ui kendo-asp.net-mvc kendo-scheduler
我正在使用弹出式kendo网格,我使用添加新记录和编辑模式,我希望在添加新记录时通过html帮助程序更改弹出窗口kendo网格的标题.
<div class="k-rtl">
@(Html.Kendo().Grid<KendoSample.Models.Person>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.PersonId).Title("Person Code").Width(100).Sortable(true);
columns.Bound(p => p.Name).Title("Name").Width(200).Sortable(true);
columns.Bound(p => p.Family).Title("Family").Sortable(false);
columns.Command(c => { c.Edit().Text("Edit").CancelText("Cancel").UpdateText("save"); c.Destroy().Text("Delete"); });
})
.Pageable()
.ToolBar(s => { s.Create().Text("?????"); })
.Editable(c => { c.TemplateName("Default").Mode(GridEditMode.PopUp); c.Window(x => x.Title("??????")); })
.Scrollable()
.Sortable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Model(c => c.Id(p => p.PersonId))
.Create(c => c.Action("Read", "Home"))
.Read(read => read.Action("EditingPopup_Read", "Grid"))
.Update(update => update.Action("EditingPopup_Update", "Grid"))
.Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))
.ServerOperation(true)
.PageSize(8)
.Read(read => read.Action("EditingPopup_read", "Home"))
)
.Sortable() …Run Code Online (Sandbox Code Playgroud) 我有一个基于类似于模型的网格
public class UserModel
{
...
public IList<UserOrgModel> UserOrg {get; set;}
...
}
Run Code Online (Sandbox Code Playgroud)
此Grid设置为.Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("...")并打开此editorTemplate以编辑我选择的行(通过按Action按钮).
此编辑器模板还包含一个将绑定到我的集合的网格.
我用这种方式定义了网格
@(Html.Kendo().Grid(Model.UserOrg)
.Name("blabla")
.Columns(col =>
{
col.Bound(c => c.Id);
})
)
Run Code Online (Sandbox Code Playgroud)
当我这样做时,基于我的集合的网格总是空的.任何想法如何使用Kendo UI及其网格来做我想要的.我不知道如何将我的网格绑定到我的模型的"集合".
如何向kendo添加自定义工具editor toolbar?
我想添加拼写检查器,媒体管理器和剪切,复制,粘贴,剪切,单词复制和其他一些工具.
我在MVC应用程序中使用Kendo编辑器.
美好的一天,我需要将两个日期之间的天数输入两个kendo.DateTimePickers.
我的解决方案总是以NaN值结束.RentStartDate和RentEndDate作为DateTime存储在db中.
感谢您的意见.
<script>$("#RentEndDate").change(function () {
var startDate = kendo.toString($("#RentStartDate").data("kendoDateTimePicker").value(), "dd.MM.yyyy");
var endDate = kendo.toString($("#RentEndDate").data("kendoDateTimePicker").value(), "dd.MM.yyyy");
alert(calculate(startDate, endDate));
});
function calculate(first, second) {
var diff = Math.round((second - first) / 1000 / 60 / 60 / 24);
return diff;
}
Run Code Online (Sandbox Code Playgroud)
CreateOrders.cshtml
<h4>Termín p?j?ení</h4>
<div class="t-col t-col-6 t-col-xs-12 t-col-sm-12 t-col-md-12 col-sm-6">
<label for="rentStartPicker">P?j?it od</label>
@(Html.Kendo().DatePickerFor(model => model.RentStartDate).Name("rentStartPicker").HtmlAttributes(new { style = "height:28px;", required = "required", validationmessage = "Vyberte datum" }))
</div>
<div class="t-col t-col-6 t-col-xs-12 t-col-sm-12 t-col-md-12 col-sm-6">
<label for="rentEndPicker">P?j?it do</label>
@(Html.Kendo().DatePickerFor(model …Run Code Online (Sandbox Code Playgroud) kendo-ui ×7
kendo-grid ×5
asp.net-mvc ×4
c# ×4
customtool ×1
javascript ×1
kendo-editor ×1
popup ×1
razor ×1