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

Empty grid on startup

2 Answers 1099 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Atanu
Top achievements
Rank 1
Atanu asked on 15 Oct 2012, 12:40 PM
Hi

I have a kendo ui grid which should be empty at startup. (Actually its a popup containing a kendo grid)

I have tried using the following code

$("#MyGrid").empty();
$("#MyGrid").kendoGrid();

But it make the grid header and footer invisible.

In Telerik I used to do it with grid.dataBind(null) which works perfectly

Please advise.

2 Answers, 1 is accepted

Sort by
0
Atanu
Top achievements
Rank 1
answered on 16 Oct 2012, 10:49 AM
Any update on this will be highly appreciated
1
Accepted
Vladimir Iliev
Telerik team
answered on 16 Oct 2012, 12:34 PM
Hi Atanu,

 
You should set the AutoBind configuration option to false, and then to populate the Grid with data you should use the Read method of the DataSource.

e.g.:

@(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.ProductID).Groupable(false);
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.UnitPrice);
        columns.Bound(p => p.UnitsInStock);
    })
    .AutoBind(false)
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Products_Read", "Grid"))
    )
)
 
<script type="">
    $(document).ready(function () {
        //Populate the Grid with data:
        $("#Grid").data("kendoGrid").dataSource.read();
    })
</script>


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!
Tags
Grid
Asked by
Atanu
Top achievements
Rank 1
Answers by
Atanu
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or