我使用editable: "popup" Telerik的演示页面上显示的方式编辑网格.编辑网格后,我希望网格刷新.在编辑网格后,网格是否有任何调用的事件?
我试图使用数据绑定事件.在这种情况下,我将数据源读取,但它告诉我刷新网格是一个无限循环.我试图使用saveChanges事件,但它无法正常工作.
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName);
columns.Bound(p => p.UnitPrice).Width(100);
columns.Bound(p => p.UnitsInStock).Width(100);
columns.Bound(p => p.Discontinued).Width(100);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Pageable()
.Sortable()
.Scrollable()
.Events(events => events.Change("saveChanges "))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.ProductID))
.Create(update => update.Action("EditingPopup_Create", "Grid"))
.Read(read => read.Action("EditingPopup_Read", "Grid"))
.Update(update => update.Action("EditingPopup_Update", "Grid"))
.Destroy(update => update.Action("EditingPopup_Destroy", "Grid")) …Run Code Online (Sandbox Code Playgroud) 我想构建一个格式为日期dd // MM/yyyy的Kendo UI Grid.但是,我发现的所有问题都是用代码格式("{0:d}")解决的; .所以,我尝试过如下代码:
GridBoundColumnBuilder<TModel> builder = par.Bound(field.Name);
switch (field.Type.Type)
{
case CType.Boolean:
builder = builder.ClientTemplate(string.Format("<input type='checkbox' #= {0} ? checked='checked' : '' # disabled='disabled' ></input>", field.Name));
break;
case CType.Datetime:
builder = builder.Format("{0:d}");
break;
case CType.Decimal:
case CType.Double:
builder = builder.Format("{0:0.00}");
break;
}
Run Code Online (Sandbox Code Playgroud)
另一种格式工作正常,只是DateTime不起作用.
我有这个结果的日期时间= /日期(1377020142000)/
假设我有这样的数据:
[
{ID: 1, SomeForeignKeyID: 4, IsFkEnabled: true},
{ID: 2, SomeForeignKeyID: 9, IsFkEnabled: false}
]
Run Code Online (Sandbox Code Playgroud)
Kendo Grid正在使用这些数据:
columns.Bound(m => m.ID);
columns.ForeignKey(p => p.SomeForeignKeyID, ViewBag.ForeignKeys as IEnumerable<object>, "Value", "Name");
Run Code Online (Sandbox Code Playgroud)
这是问题所在:如何使ForeignKey列可编辑,但只能在行中,IsFkEnabled == true?编辑模式是InCell.
我有Kendo网格,我设置数据源使用它
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("GetWorker", "Worker"))
Run Code Online (Sandbox Code Playgroud)
我的页面上有按钮,当我按下此按钮时,我想要更改数据源(使用java脚本).我想做这样的事情
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.Read(read => read.Action("GetDisabled", "Worker"))
Run Code Online (Sandbox Code Playgroud)
我尝试这样做
var grid = $("grid").data("kenodGrid");
grid.dataSource().read()
Run Code Online (Sandbox Code Playgroud)
但我不知道在grid.dataSource()之后该怎么做.我该如何更改数据源?Thnaks,希望对你有所帮助
javascript asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc
我有一个kendo Grid如下.
@(Html.Kendo().Grid<RevenueModel>()
.Name("WeeklyRevenue")
.Resizable(resizing => resizing.Columns(true))
.Columns(columns =>
{
columns.Bound(p => p.Number).Width(100);
columns.Bound(p => p.Type).Width(100);
columns.Bound(p => p.Week1).Format("{0:c}");
columns.Bound(p => p.Week2).Format("{0:c}");
columns.Bound(p => p.Week3).Format("{0:c}");
columns.Bound(p => p.Week4).Format("{0:c}");
columns.Bound(p => p.Week5).Format("{0:c}");
columns.Bound(p => p.TotalRevenue).Format("{0:c}");
})
.Scrollable()
.Events(events => events.Change("onChange").DataBound("onDataBound"))
.DataSource(dataSource => dataSource.Ajax().Read(read => read.Action("WeeklyRevenue", "Home")).ServerOperation(false))
.Pageable(pager => pager.Refresh(true))
)
Run Code Online (Sandbox Code Playgroud)
这是我的控制器代码
public ActionResult WeeklyRevenue([DataSourceRequest]DataSourceRequest request)
{
...
DataSourceResult result = res.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是我想在Grid读取数据时发送更多数据,如下所示;
public ActionResult WeeklyRevenue([DataSourceRequest]DataSourceRequest request, string AdditionalParam)
Run Code Online (Sandbox Code Playgroud)
我找不到任何解决方法如何做到这一点.提前致谢.
使用VS'12,Asp.net - C# - InternetApplication Template,KendoUI,EF Code First
这是我的MVC BundleConfig.cs
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
// The Kendo CSS bundle
bundles.Add(new StyleBundle("~/Content/kendo").Include(
"~/Content/kendo/kendo.common.*",
"~/Content/kendo/kendo.default.*"));
// The Kendo JavaScript bundle// or kendo.all.min.js if you want to use Kendo UI Web and Kendo UI DataViz
bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
"~/Scripts/kendo/kendo.web.min.js",
"~/Scripts/kendo/kendo.aspnetmvc.min.js"));
Run Code Online (Sandbox Code Playgroud)
另外你应该知道我在最后运行这两行 BundleConfig.cs
bundles.IgnoreList.Clear();
bundles.DirectoryFilter.Clear();
Run Code Online (Sandbox Code Playgroud)
当我尝试托管项目时,我一直在获得403 Access Denied,File Forbidden Errors.
我曾尝试使用This Awesome Post作为参考,我确实改变了一些内容,但错误仍然存在.
我想是因为KendoUI附带的.min文件,但我无法确定.
供您参考,这是我的_Layout.cshtml,以及我如何调用脚本.
@Scripts.Render("~/bundles/jquery")
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/kendo")
@Scripts.Render("~/bundles/kendo")
Run Code Online (Sandbox Code Playgroud) asp.net-mvc web-deployment kendo-ui bundling-and-minification kendo-asp.net-mvc
我的页面中有一个kendo ui网格,有一些列.现在我想添加一个列,显示行号.我该怎么做?谢谢.
我在尝试使用KendoUI网格为Visual Studio 2013中开发的ASP.NET MVC(.net 4.5)应用程序时遇到异常.我已将网格配置为使用InLine编辑并已明确将Batch设置为false数据源部分.这是作为局部视图呈现的.应该注意的是,如果GridEditMode.InLine设置为GridEditMode.InCell,则不会抛出异常.
您必须使用InCell编辑模式进行批量更新.
描述:执行当前Web请求期间发生未处理的异常.请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息.
异常详细信息:System.NotSupportedException:必须使用InCell编辑模式进行批量更新.
@using Kendo.Mvc.UI
@model MyApp1.Data.DataModels.Agent
@(Html.Kendo().Grid<MyApp1.Data.ViewModels.PhoneNumberVM>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Number);
columns.Bound(p => p.Description);
columns.Command(command => command.Edit()).Width(90);
columns.Command(command => command.Destroy()).Width(90);
})
.ToolBar(toolBar =>
{
toolBar.Create().Text("Add Phone Number");
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.PhoneNumberId);
model.Field(p => p.PerId).Editable(false).DefaultValue(@Model.PerId);
})
.Read(read => read.Action("_GetPhones", "Pers", new { AgentId = Model.AgentId }))
.Create(create => create.Action("_AddPhone", "Pers"))
.Update(update => update.Action("_EditPhone", …Run Code Online (Sandbox Code Playgroud) 我想将数据从Kendo Grid发布到服务器,并将其保存到数据库中.
为此,我使用了这样的形式:
@using (Html.BeginForm("MainDocumentSave","Document"))
{
<div class="row-fluid">
<div class="span10">
@(Html.Kendo().Grid<Invoice.Models.ViewModels.SegmentViewModel>()
.Name("Segment")
.TableHtmlAttributes(new { style = "height:20px; " })
.Columns(columns =>
{
columns.Bound(p => p.AirlineShortName).EditorTemplateName("AirlineEditor").Title("Airline").ClientTemplate("#=AirlineName#").Width(5);
columns.Bound(p => p.DepartureDate).Width(9);
columns.Bound(p => p.Arrives).EditorTemplateName("ArrivalLocation").Title("Arrival").ClientTemplate("#=Arrives#").Width(5);
columns.Bound(p => p.ArrivalDate).Width(7);
columns.Bound(p => p.FlightNumber).Width(8);
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Navigatable()
.Sortable()
.Scrollable(scr => scr.Height(200))
.Scrollable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.AirlineName))
.Create("Editing_Create", "Grid")
.Read("Segment_Read", "Document")
.Update("Editing_Update", "Grid")
.Destroy("Editing_Destroy", "Grid")
)
)
</div>
</div>
<button type="submit" class="btn btn-primary"> Save Segments</button>
} …Run Code Online (Sandbox Code Playgroud) asp.net-mvc asp.net-mvc-3 kendo-ui kendo-grid kendo-asp.net-mvc
如何在Kendo模板中为kendo grid动态设置列.在我的kendo网格中,列可以根据用户的喜好动态更改.如何动态创建Kendo模板?我使用的是Kendo JavaScript,我可以切换到Kendo MVC,如果相同的话我可以在那里实现.有没有其他方法来实现这一目标?
<script id="rowTemplate" type="text/x-kendo-template">
<tr class="k-master-row">
<td>
<div>#=column1#</div>
</td>
<td><span class="mydesign" title="column2#"</span></td>
<td>#column3#</td>
<td>#=column4#</td>
</tr>
</script>
Run Code Online (Sandbox Code Playgroud)
编辑:在Kendo网格中,我们正在动态设置列.现在问题是我们如何设置内容表和标题表的动态宽度.如果超过最大宽度,我们如何启用水平滚动条.有没有办法实现这个目标?
asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc asp.net-mvc-5