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 click event this grid.
  • in same context e.target button, closest table row.

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -