我已经创建了asp.net MVC 4应用程序,其中我使用的是实体框架,类"Data"就是模型.
AdventureWorksTrainingEntities _dbContext = new AdventureWorksTrainingEntities();
Data _data = new Data(); //Model
Run Code Online (Sandbox Code Playgroud)
现在我想将表的数据显示到kendo网格.在控制器中,我使用以下代码:
public ActionResult Index()
{
List<Movie> dataForGrid= _dbContext.Movies.ToList();
return View(dataForGrid);
}
Run Code Online (Sandbox Code Playgroud)
现在我不知道在Kendo Grid中显示数据(我是kendo和MVC的新手).我也试过以下但没有工作:
@model IEnumerable<MvcApp.Models.Data>
@using Kendo.Mvc.UI
@{
ViewBag.Title = "Index";
}
<h2>Grid For Data</h2>
Html.Kendo().Grid<Order>()
.Name("Grid")
.DataSource(dataSource => dataSource // Not implemented
)
Run Code Online (Sandbox Code Playgroud) asp.net-mvc asp.net-mvc-4 kendo-ui kendo-grid kendo-asp.net-mvc
我正在使用用于Kendo UI的ASP.NET MVC包装器,我正在尝试在自定义模板(x-kendo-template)中绑定多个下拉列表.我无法弄清楚如何使用ASP.NET MVC Wrapper(这类似于这个问题:如何使用调度程序将DropDownList绑定到编辑器模板中的DataSource?).
有一些关于使用Kendo Web版本的示例,但没有完整的示例显示使用自定义弹出编辑器,调度程序包含从URL(json数据)中提取数据的下拉列表.
有端到端的例子吗?我可以用数据加载调度程序.问题在于自定义模板和下拉列表绑定.
编辑:
在广泛搜索之后,我偶然发现了Telerik使用ASP.NET MVC中的Kendo UI Scheduler的"入门"页面.他们(Telerik)确实需要更好地将Demos与文档之间的交叉连接到API和示例(以下是示例)
我还创建了一个博客文章,它包含了调度程序的所有内容(从数据库表到视图),你可以在这里看到.带有ASP.NET MVC和Peta Poco的Kendo UI Scheduler
这个例子揭示了演示和文档没有做到的一些亮点,比如他们在网上示例中使用的ViewModel:
C#ViewModel
public class Projection : ISchedulerEvent
{
public string Title { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public string Recurrence { get; set; }
public string RecurrenceRule { get; set; } …Run Code Online (Sandbox Code Playgroud) 我需要在特定列上默认对网格进行分组,并且不允许用户删除该列上的分组.这可能吗?
我在Kendo Window里面有一个Kendo Grid.如何使用包装器启用其水平滚动?
我尝试过任何东西,但都没有奏效.我尝试的最后一件事是围绕Grid,宽度有限div.
@(Html.Kendo().DropDownListFor(model => model.ServiceID)
.OptionLabelTemplate("#=optionLabel#")
.ValueTemplate("#=Code#(#=Rate#) - #=Description#")
.Template("#=Code#(#=Rate#) - #=Description#")
.DataTextField("Code")
.DataValueField("ServiceID")
.DataSource(d =>
{
d.Read(read =>
{
read.Action("GetServiceRepository", "Service").Data("...")
.Type(HttpVerbs.Post);
});
})
.OptionLabel(new { optionLabel = Resources.Wording.SelectOne, ServiceID = 0, Rate = 0, Code = "" })
)Run Code Online (Sandbox Code Playgroud)
我有一个Kendo Dropdownlist,它使用HTML帮助方式而不是JQuery方式初始化.
无论如何使用JSONcontentType而不是默认值来发布/ Service/GetServiceRepository的发布请求application/x-www-form-urlencoded?
我正在使用ASP.MVC和Kendo作为我的Web应用程序.
目前,我有这段代码:
public FileResult Export([DataSourceRequest]DataSourceRequest request)
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
DataSourceRequest可用Kendo.Mvc.dll.目前,我从这个网站获得了.dll .
我的问题是我可以从NuGet获得这个dll?
谢谢!
我正在尝试在异步模式下使用Kendo UI Upload(MVC包装器).事情似乎在Chrome中运行良好,但在IE中没有这样的运气(截至目前仅在IE 9中测试过).当它启动上传时,我可以看到它命中我的操作方法,并且请求包含我期望的数据,但实际上没有任何内容被保存.
代码示例如下:
_EditForm.cshtml(上传的位置)
@(Html.Kendo().Upload()
.Name(string.Format("upload{0}", "background"))
.Multiple(true)
.Events(evt => evt.Success("refreshBackgroundImages"))
.Messages(msg => msg.DropFilesHere("drag and drop images from your computer here")
.StatusUploaded("Files have been uploaded"))
.Async(a => a.AutoUpload(true)
.SaveField("files")
.Save("UploadImage", "Packages", new { siteId = Model.WebsiteId, type = "background" })))
Run Code Online (Sandbox Code Playgroud)
控制器ActionMethod
[HttpPost]
public ActionResult UploadImage(IEnumerable<HttpPostedFileBase> files, Guid siteId, string type)
{
var site = _websiteService.GetWebsite(siteId);
var path = Path.Combine(_fileSystem.OutletVirtualPath, site.Outlet.AssetBaseFolder);
if (type == "background")
{
path = Path.Combine(path, _backgroundImageFolder);
}
else if (type == "image")
{
path …Run Code Online (Sandbox Code Playgroud) asp.net-mvc asyncfileupload asp.net-mvc-4 kendo-ui kendo-asp.net-mvc
我是kendo.ui的首发,我写了这段代码来创建kendo.ui.grid
@(Html.Kendo().Grid<BrandViewModel>(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.BrandName);
columns.Bound(p => p.BrandAbbr);
columns.Bound(p => p.SrcImage);
columns.Command(command => command.Custom("Edit").Click("editItem"));
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("CustomCommand_Read", "Brand"))
.Model(model => model.Id(p => p.Id))
)
)
Run Code Online (Sandbox Code Playgroud)
当用户单击网格中的编辑按钮时,它将在kendo.ui.window中显示编辑视图,用户可以编辑数据.
@(Html.Kendo().Window().Name("Details")
.Title("Customer Details")
.Visible(false)
.Modal(true)
.Height(400)
.Draggable(true)
.Width(300)
.Events(events => events.Close("onClose"))
)
<script type="text/x-kendo-template" id="template">
<div id="details-container">
<!-- this will be the content of the popup -->
BrandName: <input type='text' value='#= BrandName #' />
</div>
</script>
<script type="text/javascript">
var detailsTemplate = kendo.template($("#template").html());
var windowObject;
$(document).ready(function …Run Code Online (Sandbox Code Playgroud) 我使用具有分层网格(父网格和子网格)的kendo网格和custom.command; 单击Child的查看按钮(在父网格运行正常的情况下),它应该调用java脚本函数,显示该行的详细信息,但发生的是它调用javascript两次,第一次有正确的行ID(即相同的行)然后第二次错误的id(即父网格的第一个id).
代码如下.
家长网
@(Html.Kendo().Grid<IRIS.Web.BackOffice.ViewModels.AuditListView>()
.Name("GridAudit")
.Columns(column =>
{
column.Bound(model => model.LogId).Visible(true);
column.Bound(model => model.Date);
column.Bound(model => model.Time);
column.Bound(model => model.User).ClientTemplate(IRIS.Common.Helpers.ViewTemplateFormats.GetUnWrapColum("User"));
column.Bound(model => model.Module).ClientTemplate(IRIS.Common.Helpers.ViewTemplateFormats.GetUnWrapColum("Module")).Width(150);
column.Bound(model => model.Activity);
column.Bound(model => model.Description).ClientTemplate(IRIS.Common.Helpers.ViewTemplateFormats.GetUnWrapColum("Description")).Width(200);
column.Command(command =>
{
command.Custom("View").Text(" ").Click("onParentAuditHirarchy");
}).Width("6em").Title("Actions");
})
.Reorderable(reorder => reorder.Columns(true))
.Selectable(select => select.Enabled(true).Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))
.ClientDetailTemplateId("template1")
.Sortable()
.Scrollable(scroll => scroll.Enabled(false))
.Filterable()
.Pageable(page => page.ButtonCount(5))
.HtmlAttributes(new { style = "height:400px" })
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Audit_Load", "AuditLog").Data("getSearchData")
)
.PageSize(11)
)
)
Run Code Online (Sandbox Code Playgroud)
儿童网格
<script id="template1" type="text/kendo-tmpl">
@(Html.Kendo().Grid<IRIS.Web.BackOffice.ViewModels.AuditListView>()
.Name("GridDetails" + "#=LogId#")
.AutoBind(true)
.Resizable(resize …Run Code Online (Sandbox Code Playgroud) 我有一个问题,对我来说这很奇怪!我在两个不同的地方有2个解决方案.它们两个相似,但其中一个比另一个更老.当我在它上面运行一个Kendo Grid时,新版本出现了问题.但是当我在新版本旁边打开旧版本的解决方案时,我强调只是打开没有运行,新版本会没问题!对我来说,如何解决这个问题以及另一个解决方案如何通过打开解决方案来解决这个问题非常奇怪?我认为有些东西已经损坏但我不知道,那是什么.我怎么解决这个问题?
我已经为Asp.net MVC使用了Visual Studio 2013,C#和Kendo.
Jahan.Blog.sln文件:(新版本)
Microsoft Visual Studio Solution File, Format Version 12.00
Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Model.DbFirst", "Applications\Jahan.Blog.Model.DbFirst\Jahan.Blog.Model.DbFirst.csproj", "{EE04EA76-1CFE-4484-B6C5-7C5232B3F1C4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Model", "Applications\Jahan.Blog.Model\Jahan.Blog.Model.csproj", "{944336E2-DC84-451C-BB1D-86C619A1770D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Web.Mvc", "Applications\Jahan.Blog.Web.Mvc\Jahan.Blog.Web.Mvc.csproj", "{09F658AE-5DDD-44DA-950D-6C3CF1259206}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Blog.Web.TestHtml", "Applications\Jahan.Blog.Web.TestHtml\Jahan.Blog.Web.TestHtml.csproj", "{69D02E00-1663-464B-B07A-C129B8D29C8D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.HtmlPage", "Applications\Test.HtmlPage\Test.HtmlPage.csproj", "{5C1E487D-6421-470E-9398-11CB230D5435}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Blog", "Blog", "{790963C2-9AB6-440E-96B3-48A29CF9663A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProjectsForTest", "ProjectsForTest", "{F7F4128F-4141-434A-9655-8BA7B6806570}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{C3F7006C-B13C-447E-BABB-6561B38EB71B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jahan.Infrastructure.DataAccess", "Applications\Jahan.Infrastructure.DataAccess\Jahan.Infrastructure.DataAccess.csproj", "{511E08CF-B782-49AF-BA10-E52BCDA4140D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = …Run Code Online (Sandbox Code Playgroud) asp.net-mvc runtime visual-studio kendo-grid kendo-asp.net-mvc
kendo-grid ×6
kendo-ui ×6
asp.net-mvc ×5
javascript ×2
.net ×1
c# ×1
dll ×1
jquery ×1
json ×1
kendo-ui-mvc ×1
nuget ×1
runtime ×1