Kendo UI grid, search box in toolbar in mvc -
kendo-grid search box in toolbar in mvc razor syntax,
i facing need toolbar in searching box , searching box search grid data.
just copy , paste code bind mvc model , custom button(crud) , search box in toolbar in kendo grid template
<div> @(html.kendo().grid(model) .name("diagnosistestgrid") .columns(columns => { columns.bound(c => c.description).title("description"); columns.bound(c => c.cost).title("cost"); columns.bound(c => c.costingrequired).title("cost req."); columns.bound(c => c.dxtestid).clienttemplate(@" <a href='/diagnosistest/details/#=dxtestid#' class = 'dialog-window'>detail</a> | <a href='/diagnosistest/edit/#=dxtestid#' class = 'dialog-window' >edit</a> | <a href='/diagnosistest/delete/#=dxtestid#' class = 'dialog-window'>delete</a> ").title(""); }) .toolbar(toolbar => { toolbar.template(@<text> <div class="toolbar"> <div class="row"> <div class="col-md-4"> <div class="input-group"> <span class="input-group-addon"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></span> <input type="text" class="form-control" id='fieldfilter' placeholder="search for..."> <span class="input-group-btn"> <button class="btn btn-default" type="button"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span></button> </span> </div> </div> </div> </div> </text>); }) .resizable(resizing => resizing.columns(true)) .sortable(sorting => sorting.enabled(true)) .reorderable(reorder => reorder.columns(true)) .pageable() .datasource(datasource => datasource .ajax() .pagesize(5) .serveroperation(false) )) </div>
script search box. , filter grid items
<script> $(document).ready(function () { $("#fieldfilter").keyup(function () { var value = $("#fieldfilter").val(); grid = $("#diagnosistestgrid").data("kendogrid"); if (value) { grid.datasource.filter({ field: "description", operator: "contains", value: value }); } else { grid.datasource.filter({}); } }); });
Comments
Post a Comment