How to Disable AutoBind in KendoGrid


KendoUI is a collection of UI controls which use for UI design. KendoUI have very rich controls library. KendoGrid support different data source to show data into grid like json data, json path etc.
KendoGrid is automatically bind data from data source into grid.

But some time we need to bind data into certain conditions. In this demo we showing how to disable auto binding in KendoGrid.

For disable autobind in kendoGrid use AutoBind false method of grid  like

.AutoBind(false)

and for bind data into grid call .dataSource.read() method like we using in following example


?
1
2
3
4
5
6
function ShowGridData()
{
$("#deviceGrid").data("kendoGrid").dataSource.read();
}
<a href="javascript:void(0);" onclick="ShowGridData();" class="btn btn-primary">Submit</a>
function ShowGridData()
{
$("#deviceGrid").data("kendoGrid").dataSource.read();
}

<a href="javascript:void(0);" onclick="ShowGridData();" class="btn btn-primary">Submit</a>


We are using following grid.

?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
@(Html.Kendo().Grid<MDM.DEP.Entities.Custom.Apple.OrderDeviceStatus>()
                               .Name("deviceGrid")
                               .AutoBind(false)
                                           .ToolBar(e => e.Template("<a class='btn btn-flat btn-default' onclick='gridAllFilterReset(deviceGrid)' href='javascript:void(0)'></span>Clear all filter</a>"))
                               .Columns(columns =>
                               {
                                   columns.Bound(p => p.DeviceID).Title("Device ID").Filterable(true);
                                   columns.Bound(p => p.AppleStatus).Title("Apple Status").Filterable(true);
                                   columns.Bound(p => p.IDEPStatus).Title("IDEP Status").Filterable(true);
                               })
                               .DataSource(ds => ds
                                   .Ajax()
                                           .Read(read => read.Action("Index", "OrderEnquiry").Data("forOrderNumber"))
                                   .PageSize(PageSize)
                               )
                           .Events(e => e.DataBound("onDataBound"))
                               .Pageable()
                               .Sortable()
                               .Resizable(e => e.Columns(true))
                                .Pageable(pager => pager
                                      .Refresh(true)
                                   )
                               .Filterable(filterable => filterable
                                   .Extra(false)
                                   .Operators(operators => operators
                                       .ForString(str => str.Clear()
                                           .StartsWith("Starts with")
                                           .EndsWith("Ends with")
                                           .Contains("Contains")
                                           .DoesNotContain("Not contains")
                                           )
                                       )
                                   )
               )
@(Html.Kendo().Grid<MDM.DEP.Entities.Custom.Apple.OrderDeviceStatus>()
                               .Name("deviceGrid")
                               .AutoBind(false)
                                           .ToolBar(e => e.Template("<a class='btn btn-flat btn-default' onclick='gridAllFilterReset(deviceGrid)' href='javascript:void(0)'></span>Clear all filter</a>"))
                               .Columns(columns =>
                               {
                                   columns.Bound(p => p.DeviceID).Title("Device ID").Filterable(true);
                                   columns.Bound(p => p.AppleStatus).Title("Apple Status").Filterable(true);
                                   columns.Bound(p => p.IDEPStatus).Title("IDEP Status").Filterable(true);

                               })
                               .DataSource(ds => ds
                                   .Ajax()
                                           .Read(read => read.Action("Index", "OrderEnquiry").Data("forOrderNumber"))
                                   .PageSize(PageSize)
                               )
                           .Events(e => e.DataBound("onDataBound"))
                               .Pageable()
                               .Sortable()
                               .Resizable(e => e.Columns(true))
                                .Pageable(pager => pager
                                      .Refresh(true)
                                   )
                               .Filterable(filterable => filterable
                                   .Extra(false)
                                   .Operators(operators => operators
                                       .ForString(str => str.Clear()
                                           .StartsWith("Starts with")
                                           .EndsWith("Ends with")
                                           .Contains("Contains")
                                           .DoesNotContain("Not contains")
                                           )
                                       )
                                   )
               )



Previous
Next Post »
Thanks for your comment