Tuesday, 15 April 2014

c# - Add checkbox column without binding in Kendo Grid -



c# - Add checkbox column without binding in Kendo Grid -

i seek add together checkbox column in kendo grid. utilize code in link :

http://www.telerik.com/support/code-library/select-grid-rows-using-checkboxes-and-preserve-it-between-the-pages

but doesn't work razor page. here's code :

cshtml :

@(html.kendo().grid<iquestarchive>().name("archivesgrid") .datasource(datasource => datasource.ajax().read(read => read.action("archives_read", "home").type(httpverbs.get)) .sort(sort => sort.add("name").ascending())).columns(columns => { columns.template(@<text></text>).clienttemplate("<input type='checkbox' class='checkbox'/>").title("<input type='checkbox'/>").width(10); columns.bound(request => request.readablename).title("name"); }).sortable().selectable(builder => builder.mode(gridselectionmode.multiple).type(gridselectiontype.row)))

script:

//bind click event checkbox $("#archivesgrid").table.on("click", ".checkbox" , selectrow); //on click of checkbox: function selectrow() { var checked = this.checked, row = $(this).closest("tr"), grid = $("#archivesgrid").data("kendogrid"), dataitem = grid.dataitem(row); checkedids[dataitem.id] = checked; if (checked) { //-select row row.addclass("k-state-selected"); } else { //-remove selection row.removeclass("k-state-selected"); } }

i don't understand what's going wrong , if compare code in link before it's same logic...:s

you need take closer look; can tell 1 difference; you're doing

$("#archivesgrid").table.on("click", ".checkbox" , selectrow);

whereas demo

var grid = $("#grid").kendogrid({ //... }).data("kendogrid"); //bind click event checkbox grid.table.on("click", ".checkbox" , selectrow);

it's of import understand code doing can debug it. jquery elements don't have table property. it's property of kendo ui grid widget.

c# asp.net-mvc razor kendo-ui kendo-grid

No comments:

Post a Comment