有没有办法在通过ajax重新加载网格后触发事件?
我看到了RequestEnd事件.但这似乎发生在请求返回时,但在网格刷新之前.
我也看到了DataBound事件.但这比RequestEnd更早发生,
同样当我实现DataBound事件时,我的标题消失了..
我不得不诉诸这个黑客
function requestEnd(o) {
console.debug('request ended.', o);
setTimeout(refreshEditable, 500); // enough time to render the grid
}
function refreshEditable() {
// perform my actions on controls within grid content
}
Run Code Online (Sandbox Code Playgroud)
作为旁注..我很难找到可靠的kendo grid mvc API参考.当我谷歌为它,我得到这个:http: //docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/migration/widgets/grid 这是一个很小的集合 - 和一些"事件",但那些不符合我在razor intelisense中看到的.
更新:添加数据绑定定义
$('#grid').kendoGrid({
dataBound: function(e) {
console.debug('data bound..');
}
});
Run Code Online (Sandbox Code Playgroud)
这里是网格ajax的定义
.Ajax().Read(read => read
.Action("FilesRead", "SomeController")
.Data("readData"))
function readData() {
return {
IncludeChildren: $("#IncludeChildren").is(':checked'),
SearchString: $('input[id=SearchString]').val()
};
}
Run Code Online (Sandbox Code Playgroud)
我可以看到在进行ajax调用时触发DataBound,而不是在它返回后触发.
更新
更正了DataBound事件挂钩. …
destroy()
在KendoUI Grid中调用然后在new上重新创建表时DataSource
:为什么旧表列仍然存在?
这里唯一保留说法的元素是元素.如何告诉网格读取新的数据源列(它读取其他所有正确的内容).
(如果我制作了2个不同的元素,它们都填充正确,但我只是保留1个元素并通过destroy和reinit替换元素表)
我Telerik Gridview
用于显示记录列表,我有超过10页我正在使用此gridview与以下常见事件代码复制粘贴(有一些小的更改)在所有这些页面上:
protected void Page_Load(object sender, EventArgs e)
{
DisplayRecords()
}
public void DisplayRecords()
{
//Grid view names are different on different pages.
GridView1.DataSource=Fetching records from database.
GridView1.DataBind();
}
protected void GridView1_SortCommand(object sender, GridSortCommandEventArgs e)
{
DisplayRecords()
}
protected void GridView1_PageIndexChanged(object sender, GridPageChangedEventArgs e)
{
var index = e.NewPageIndex;
DisplayRecords()
}
protected void GridView1_PageSizeChanged(object sender, GridPageSizeChangedEventArgs e)
{
var size = e.NewPageSize;
DisplayRecords()
}
Run Code Online (Sandbox Code Playgroud)
这是我的一页继承自以下页面:
public partial class LoadSettings : ParentPage
{
//Load events and other …
Run Code Online (Sandbox Code Playgroud) 我正在使用telerik mvc网格.在我的表中,我为字段定义了唯一键.在控制器中我使用try ... catch在DbUpdateException中捕获错误.
在catch块中我想处理错误并在视图中显示错误消息.所以使用以下行,
ModelState.AddModelError("PROGRAM_ID", "Access for this program already exists.");
return View();
Run Code Online (Sandbox Code Playgroud)
但这并没有显示错误信息.知道为什么吗?
在asp.net mvc页面中我使用的telerik网格看起来像这样
<div>
@(Html.Kendo().Grid<Project.Models.Bench>
()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.name).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));
columns.Bound(p => p.seatsCount).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
columns.Bound(p => p.bookedSeats).Filterable(ftb => ftb.Cell(cell => cell.Operator("gte")));
})
.Pageable()
.Sortable()
.Scrollable()
.Filterable(ftb => ftb.Mode(GridFilterMode.Row))
//.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
//.ServerOperation(true)
.Read(read => read.Action("GetBenches", "home"))
)
)
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的Bench类:
public class Bench
{
public int id { get; set; }
public string name { get; set; }
public bool bookable { get; …
Run Code Online (Sandbox Code Playgroud) 我正在使用Kendo UI网格,GridEditMode.InCell
我需要在网格列中添加删除/销毁命令的超链接,而不是默认的"删除"按钮.
我目前的代码如下:
c.Command(command => command.Destroy()).Width(90);
Run Code Online (Sandbox Code Playgroud) 如果我们知道Kendo网格中的列名,有没有办法找出网格中的列索引?
例如
EmployeeID| Name
123 | John
Run Code Online (Sandbox Code Playgroud)
我想知道'Name'字段的索引,即网格中的1.有什么建议.
谢谢.
Sanjeev
我正在尝试在下拉列表选择中为RadGrid设置过滤器中的值.
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("versionId");
column.CurrentFilterFunction = GridKnownFunction.EqualTo;
column.CurrentFilterValue = VersionsCB.SelectedValue;
RadGrid1.Rebind();
Run Code Online (Sandbox Code Playgroud)
这会填充versionId过滤器框中的版本,并将其设置为"EqualTo",但不会过滤网格.我错过了什么?
编辑:aspx:
<telerik:RadGrid
ID="RadGrid1"
runat="server"
AllowFilteringByColumn="True"
AllowPaging="True"
AllowSorting="True"
AutoGenerateDeleteColumn="True"
AutoGenerateEditColumn="True"
DataSourceID="SqlDataSource1"
GridLines="None"
AllowAutomaticDeletes="True"
AllowAutomaticInserts="True"
AllowAutomaticUpdates="True"
PageSize="50"
Skin="Hay">
<ClientSettings>
<Scrolling AllowScroll="False" UseStaticHeaders="False" ScrollHeight="620"/>
</ClientSettings>
<MasterTableView DataSourceID="SqlDataSource1" AutoGenerateColumns="False" DataKeyNames="id" CommandItemDisplay="TopAndBottom">
<Columns>
<telerik:GridBoundColumn DataField="id" DataType="System.Int32" HeaderText="id" ReadOnly="True" SortExpression="id" UniqueName="id"></telerik:GridBoundColumn>
.
.
.
<telerik:GridBoundColumn DataField="versionId" DataType="System.Int32" HeaderText="versionId" ReadOnly="False" SortExpression="versionId" UniqueName="versionId"></telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<HeaderContextMenu EnableImageSprites="True" CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
</telerik:RadGrid>
Run Code Online (Sandbox Code Playgroud) 使用Telerik MVC3网格,C#,.Net 2010;
我的剃刀视图中有一个网格:
@(Html.Telerik().Grid<ProductListItem>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.Current.Name).Sortable(true).Filterable(false).Width(150);
columns.Bound(o => o.Categories).Sortable(true).Filterable(false).Width(200);
//other column bindings...
})
.DataBinding(dataBinding => dataBinding.Ajax().Select(Model.GridAjaxRequestAction.ActionName, Model.GridAjaxRequestAction.ControllerName))
.Pageable(settings => settings.Total(Model.TotalRow))
.EnableCustomBinding(true)
.Sortable()
.Filterable()
Run Code Online (Sandbox Code Playgroud)
我想要做的是将网格的类别列设置为多行.
产品可能有很多类别,因此网格中的类别单元格应该是这样的;
Category0
Category1
Category2
Run Code Online (Sandbox Code Playgroud)
我尝试使用System.NewLine加入类别值,
并将此值分配给ProductListItem.Categories属性.它没有改变.文字仍然是单行.
提前致谢.
我正在使用Kendo UI MVC网格.该模型的一个属性是bool,所以我需要将它作为复选框呈现在网格中.默认情况下,Kendo UI会在列中将其显示为"true"和"false"值.所以你需要第一次点击获取复选框,然后第二次点击更改组合框的值.我没有设置网格的默认值,而是设置ClientTemplate,所以我得到了复选框而不是"true"和"false"值.
c.Bound(p => p.GiveUp)
.Title("Giveup")
.ClientTemplate("<input type='checkbox' id='GiveUp' name='GiveUp' #if(GiveUp){#checked#}# value='#=GiveUp#' />")
.Width(50);
Run Code Online (Sandbox Code Playgroud)
此网格使用批量编辑和网格编辑(GridEditMode.InCell)
.Editable(x => x.Mode(GridEditMode.InCell))
.DataSource(ds => ds.Ajax()
.ServerOperation(false)
.Events(events => events.Error("error"))
.Batch(true)
.Model(model => model.Id(p => p.Id))
.Read(read => read.Action("Orders", "Order").Data("formattedParameters"))))
Run Code Online (Sandbox Code Playgroud)
所以我希望能够让用户点击复选框并更改我的模型的值,但不幸的是,这不起作用.我可以看到视觉复选框的值被更改但我没有看到红色三角形标记单元格已更改,当我点击添加新项目按钮时,复选框中的值消失.
请告诉我我做错了什么.
提前致谢.
telerik-grid ×10
telerik ×6
kendo-ui ×5
telerik-mvc ×4
kendo-grid ×3
asp.net ×2
asp.net-mvc ×2
c# ×2
javascript ×2
.net ×1
delegates ×1
gridview ×1