user1537319
user1537319

Reputation:

How to not bind the values at grid load

my code is :

@(Html.Telerik().Grid<Model>()
        .Name("TestGrid")
        .ClientEvents(events =>
        {
            events.OnDataBound("validate");
            events.OnDataBinding("onDataBinding");
        })
        .DataBinding(db => db.Ajax()
                .Select("Action1", "Controller1", new { ldata, filter }).Enabled(true)
                    )
        .Columns(c =>
        {
            c.Bound(ctl => ctl.Uname)
              .ClientTemplate("<input type='radio' id='rdbutton'name='IsSelected'/>")
                //.ClientTemplate("<input name='<#= UserName #>' type='radio' />")
                .Title("").Filterable(false).Sortable(false).Width(5);
            c.Bound(itm => itm.Fname).Title("FName").Width(200).HtmlAttributes(new { @style = "vertical-align: top !important;" });
            c.Bound(itm => itm.LNAme).Title("Lname").Width(200).HtmlAttributes(new { @style = "vertical-align: top !important;" });
            c.Bound(itm => itm.Location).Title("Location").Width(200).HtmlAttributes(new { @style = "vertical-align: top !important;" });
        })
        .Selectable()
        .Sortable()
        .Filterable()
        .Pageable(pg =>
        {
            pg.PageSize(3);
        })
        )

Columns are binded since they need to retrieve the values when search.

Upvotes: 1

Views: 1673

Answers (1)

Petur Subev
Petur Subev

Reputation: 20203

Yo mate,

First suggestion - use the Kendo MVC Grid - there you have an option called AutoBind which you can set to false.

If you definitely want to use the old Grid - use the OnDataBinding event and prevent it the first time.

e.g.

var isFirst = true;

function onGridDataBinding(e){
   if(isFrist)
   {
       isFirst=false;
       e.preventDefault();
   }
}

Upvotes: 1

Related Questions