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

grid ajax empty

1 Answer 48 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.
comgiu
Top achievements
Rank 2
comgiu asked on 13 Dec 2012, 02:59 PM
hi,
I need to load the grid without data until user press search

I use this grid

@(Html.Telerik().Grid<CRM_mvc.Model.Entities.ML_vw_lstContatti>()
    .Name("Grid")
    //.TableHtmlAttributes(new { style = "width:900px" })
    .Scrollable(scrolling => scrolling.Enabled(true).Height(450))
    .Resizable(resizing => resizing.Columns(true))
    .Sortable()
    .Filterable()
    .Columns(columns =>
    {      
        columns.Command(commands => commands.Custom("edit")
                        .Text("edt")
                        .ImageHtmlAttributes(new { style = "text-align: center", @class = "t-icon t-edit" })
                        .ButtonType(GridButtonType.Image)
                        .DataRouteValues(route => route.Add(o => o.id).RouteKey("id"))
                        .Ajax(true)
                        .Action("Edit", "ML"))
                        .HtmlAttributes(new { style = "text-align: center", @class = "class='t-button t-button-icon t-grid-edit'" })
                        .Width(38);
        
         
        columns.AutoGenerate();
                         
    })
    .Pageable(p => p.Position(GridPagerPosition.Both)
                    .Style(GridPagerStyles.NextPreviousAndNumeric)
                    .PageSize(20))
    .DataBinding(dataBinding => dataBinding.Ajax().Select("LoadGridData", "ML")
                    .OperationMode(GridOperationMode.Server))
    .ClientEvents(events => events.OnDataBinding("Grid_onDataBinding")
                                  .OnCommand("Grid_onCommand"))
    .PrefixUrlParameters(false)
 
)


thanks

1 Answer, 1 is accepted

Sort by
0
comgiu
Top achievements
Rank 2
answered on 17 Dec 2012, 07:42 AM
prevent the OnDataBinding event the first time (i.e. when the page is first displayed).

    //...
    .ClientEvents(events => events.OnDataBinding("onDataBinding"))
)
  
<script type="text/javascript">
    var isFirstLoad = true;
    functionon DataBinding(e) {
        if(isFirstLoad) {
            isFirstLoad = false;
            e.preventDefault();
        }
    }
</script>



Regards,
Petur Subev
the Telerik team
Tags
Grid
Asked by
comgiu
Top achievements
Rank 2
Answers by
comgiu
Top achievements
Rank 2
Share this question
or