This is a migrated thread and some comments may be shown as answers.

How to use Kendo Grid Ajax Read event on demand

1 Answer 930 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Vlad asked on 22 Oct 2012, 10:41 PM

Hi All,

I have page with DropDownList and Telerik's Kendo UI Grid Control. When first time page is opened DropDownList has no item selected in it. When user selects value in DropDownList only then Grid should make Ajax call to the server and load corresponding data.

My code works fine when user selects item in DropDownList, but the problem is that first time when page is opened I there is no value in DropDownList and Grid should not make a call to the server.

My question is how can I prevent grid not to make a call to the server if there is no item selected in DropDowList?

Thanks a lot.

@Html.Kendo().DropDownList().Name("broker").DataTextField("GrandParentName").DataValueField("Id").BindTo(Model).SelectedIndex(@selectedIndex).Events(e => e.Change("brokerChanged"))
          .HtmlAttributes(new {style = "height: 500"})
          .Columns(c =>
                  c.Bound(p => p.Id)
                      .ClientTemplate((@Html.ActionLink("Edit", "Index", "Splits", new {Id = "OrderId"}, null).ToHtmlString().Replace("OrderId", "#=Id#")));
                  c.Bound(p => p.TradeDate)
                      .Title("Trd Dt")
                      .HtmlAttributes(new {style = "text-align: right"});
                  c.Bound(p => p.Price)
                      .HtmlAttributes(new {style = "text-align: right"});
                  c.Bound(p => p.Status)
                  c.Bound(p => p.Notional)
                      .HtmlAttributes(new {style = "text-align: right"});
          .Pageable(x =>
                  x.Messages(y => y.Display("{2} Order(s)"));
          .Resizable(resize => resize.Columns(true))
          .Reorderable(reoder => reoder.Columns(true))
          .DataSource(ds => ds.Ajax()
                            .Read(read => read.Action("Action", "MyController").Data("selectedBrokerId")))
<script type="text/javascript">
    function brokerChanged() {
        var grid = $("#Orders").data("kendoGrid");;
    function selectedBrokerId() {
        var obj = { brokerId: $("#broker").data("kendoDropDownList").value() };
        return obj;

1 Answer, 1 is accepted

Sort by
Vladimir Iliev
Telerik team
answered on 24 Oct 2012, 06:15 AM
Hi Vlad,

To disable the initial load you should disable the Autobind configuration option of the Grid:

.DataSource(dataSource => dataSource       

Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Asked by
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question