I have a grid that I can select a row on and then click a button on the grid to move that row's data item to a different grid.
This code has been working fine for months, but broke after the last official release. I upgraded to the most up to date internal release today (2013.2.814), but still no luck.
Basically, anytime I run code like this:
I get a strange error in Firebug and no code after the select line executes. The error looks a bit like this:
However, searching for the row by the selected class DOES work. E.g.:
I don't think it should matter, but the grid as well as the script executing the code above are inside a partial view that's loaded into a Menu Widget.
Here's the code for the views:
Menu Widget Declaration:
Partial View (Grid + Script):
This code has been working fine for months, but broke after the last official release. I upgraded to the most up to date internal release today (2013.2.814), but still no luck.
Basically, anytime I run code like this:
var grid = $("#ItemBook").data("kendoGrid");
console.log(grid.select()); //Errors
TypeError: r is undefined
...table)),t.css(kt?"padding-left":"padding-right",l.virtual?c+1:c),n=e('<tabl
console.log($("#SavedQuoteBook tr.k-state-selected")); //Gives tr element
console.log(grid.dataItem($("#SavedQuoteBook tr.k-state-selected"))); //Give dataItem
I don't think it should matter, but the grid as well as the script executing the code above are inside a partial view that's loaded into a Menu Widget.
Here's the code for the views:
Menu Widget Declaration:
@(Html.Kendo().Menu()
.Name("ItemMenu")
.OpenOnClick(true)
.CloseOnClick(false)
.Items(items =>
{
items.Add()
.Text("Items")
.Content(Html.Partial("ItemBook", Model.Items).ToHtmlString());
})
.Events(events =>
{
events.Open("ItemMenuOpen");
})
)
Partial View (Grid + Script):
<
script
type
=
"text/javascript"
>
function ConfigureItemBook() {
//Drives multi-selection of grid rows (Overrides native functionality)
$("#ItemBook").delegate('tbody tr', 'click', function () {
$(this).toggleClass('k-state-selected');
});
//Drive single selection by double click
$("#ItemBook").delegate('tbody tr', 'dblclick', function () {
$(this).addClass('k-state-selected');
PopulateItem();
});
}
function PopulateItem() {
var grid = $("#ItemBook").data("kendoGrid");
console.log("Manual Search");
console.log($("#ItemBook tr.k-state-selected")); //This works
console.log("Manual Search + Get DataItem");
console.log(grid.dataItem($("#ItemBook tr.k-state-selected"))); //This works
console.log("Kendo Grid Select");
console.log(grid.select()); //ERROR
console.log("Kendo Grid Select + GetDataItem");
console.log(grid.dataItem(grid.select())); //ERROR
}
</
script
>
@(Html.Kendo().Grid(Model)
.Name("ItemBook")
.TableHtmlAttributes(new { @style = "cursor:pointer;" })
.Columns(columns =>
{
columns.Bound(i => i.DateCreated).Width(90);
//Other columns omitted for brevity
})
.ToolBar(toolbar =>
{
toolbar.Custom().Text("Select").Url("#_").HtmlAttributes(new { onclick = "PopulateItem()" });
})
.Events(events =>
{
events.DataBound("ConfigureItemBook");
})
.Pageable()
.Sortable()
.Scrollable()
.Resizable(resize => resize.Columns(true))
.Reorderable(reorder => reorder.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Model(model =>
{
model.Id(i => i.ID);
})
)
)