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

[Solved] How to tell the grid to NOT bind to data on initial page load

1 Answer 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
StrandedPirate
Top achievements
Rank 1
StrandedPirate asked on 20 Apr 2012, 04:26 PM
I've got my grid all setup and bound to my model via ajax but how do I tell it NOT to bind to the data on initial page load?

There are various other things going on in my page and eventually an event fires were I tell the grid to go get its data via the client-side API like so: $("#SitesGrid").data("tGrid").ajaxRequest();

So at the moment the grid is getting the data twice on each page load which is a waste. I want to tell it to NOT get the data on initial load and at the right moment my client-side api call will tell it when its time.

@(Html.Telerik().Grid<SiteModel>()
                    .Name("SitesGrid")
                    .Filterable()
                    .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.ImageAndText))
                    .DataKeys(keys => keys.Add(c => c.SiteId).RouteKey("SiteId"))
                    .DataBinding(dataBinding => dataBinding.Ajax()
                        .Select("List", "Site")
                        .Insert("Insert", "Site")
                        .Update("Edit", "Site")
                        .Delete("Delete", "Site"))
                    .EnableCustomBinding(true)
                    .Columns(columns =>
                    {
                        columns.Command(c =>
                            {
                                c.Edit().ButtonType(GridButtonType.Image); ;
                                c.Delete().ButtonType(GridButtonType.Image); ;

                            }).Width(50);
                        columns.Bound(x => x.CustomerId).Hidden();
                        columns.Bound(x => x.DomainName)
                              .Width(250)
                              .Filterable(true);
                        columns.Bound(x => x.Title)
                              .Width(250)
                              .Filterable(true);
                        columns.Bound(x => x.CreatedOnUtc)
                              .Width(250)
                              .Filterable(true);
                    }))

1 Answer, 1 is accepted

Sort by
0
Pechka
Top achievements
Rank 1
answered on 21 Apr 2012, 07:17 AM
Yo mate,

You need to use the ondatabinding event and supress it the first time.
The same question here.
Tags
Grid
Asked by
StrandedPirate
Top achievements
Rank 1
Answers by
Pechka
Top achievements
Rank 1
Share this question
or