javascript - How to make the gird groupable false/true dynamically in JS? -
at first, grid defined this: click search button , grid reads data , becomes grouped class:
@(html.kendo().grid<student>() .name("studentgrid") .scrollable() .columns(columns => { columns.bound(o => o.class).groupable(true).title("class"); columns.bound(o => o.name).groupable(true).title("name"); columns.bound(o => o.point).groupable(true).title("point"); }).autobind(false) .datasource(datasource => datasource .ajax().group(i => i.add(a => a.class)) .read(read => read.action("getstudentpoint", "studentcontrol")) .events(events => events.error("error_handler")) ))
now want make gird groupable false , hide class column. means, not want group student data , hide class column:
$("#studentgrid").data("kendogrid").groupable( false ); $("#studentgrid").data("kendogrid").hidecolumn(0); $("#studentgrid").data("kendogrid").datasource.read();
what's wrong code?
even if grid has groupable = false, , if datasource still has group on it, output appear grouped. if add
$("#studentgrid").data("kendogrid").datasource.group("");
before datasource.read(); should clear groupings. setting grid.groupable false turns off ability drag column headers group area.
hide column should working, may need call refresh on grid afterward.
$("#studentgrid").data("kendogrid").refresh();
here small sample (not using mvc should still apply). http://jsbin.com/inageno/2/edit
Comments
Post a Comment