model view controller - MVC Kendo UI Grid = Custom Button can't return selected row id -
i want selected row "id" failed... , have totally no clue happening here. mvc html code :
@(html.kendo().grid(model) .name("grid") .htmlattributes(new { style = "margin-top: 5px" }) .columns(c => { c.bound(model => model.mgid); c.command(com => { com.custom("edit").click("edit");}); }) .pageable() .sortable() .selectable() .datasource(d => d .ajax() .pagesize(20) .model(model => model.id(i => i.mgid)) .read(r => r.action("manage_read", "manage")) .destroy(o => o.action("manage_destroy", "manage")) ) ) javascript code :
function edit() { var grid = $("#grid").data("kendogrid"); var row = grid.select(); var selectedrowindex = row.index(); //return "-1" var dataitem = grid.dataitem(row); //return "undefined" } please tell me, miss out??
if need dataitem of row containing clicked "edit" button, can use:
function edit(e) { var dataitem = this.dataitem($(e.target).closest("tr")); } note:
- in context of
clickeventthisgrid. - in same context
e.targetbutton,closesttable row.
Comments
Post a Comment