以下是我将数据加载到剑道网格的代码:
@(Html.Kendo().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.CountryName);
columns.Bound(p => p.CountryCode);
columns.Bound(p => p.CountryCodeLength);
columns.Bound(p => p.CurrencyString);
columns.Bound(p => p.CountryISOName);
})
.Pageable(p =>
{
p.Enabled(true);
p.PageSizes(new int[] { 10, 20, 30, 40, 50 });
})
.Sortable()
.Selectable()
.Groupable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(p => p.ID))
.Read(read => read.Action("Country_Read", "Country")).PageSize(10)
)
.Events(events => events.Change("GridChange"))
.ToolBar(toolbar =>
{
toolbar.Template(
@<text>
<div id="Toolbar">
<a id="Add" href="@Url.Action("Create", "Country")" title="Add New Record"></a>
<a id="Edit" title="Edit Selected Record"></a>
<a id="Delete" title="Delete Selected Record"></a>
</div>
</text>);
})
)
如何定期在10-15秒内刷新列CountryCodeLength
我尝试刷新整个网格,但我有一些弹出窗口要在同一网格内打开。因此,在使用弹出窗口刷新整个网格时,弹出窗口将丢失
请告诉我如何刷新单个列?这是我用来刷新整个网格的代码:
$(document).ready(function()
{
var refreshId = setInterval( function() {
//GET YOUR GRID REFERENCE
var grid = $("#Grid").data("kendoGrid");
grid.dataSource.read();
}, 5000);
});
var gridData = $("#Grid").data("kendoGrid").dataSource;
var data = gridData.at(0);//data at 0 Location
data.set("CountryCodeLength", 20);//set the value here
您可以使用轮询脚本来刷新值
var MyGrid = $("#MyGrid").data("kendoGrid");
var selectedItem = MyGrid.dataItem(MyGrid.select());
selectedItem.set("CountryCodeLength", 10);
MyGrid.tbody.find("tr[data-uid="" + selectedItem.uid + ""]").addClass("k-state-selected");