How to make grid not load data when first time go to the page?

5 posts, 0 answers
  1. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 12 Apr 2013 Link to this post

    How to make grid not load data when first time go  to the page? Because I have some filter condition before load data,Now when I first go to the page,It load all data  to me without filter because my filter condition is null as user have not set the filtercondition
  2. Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 13 Apr 2013 Link to this post

    Hi,

    you can set autoBind to false and then call the dataSource read method after setting the filter.

    Regards,
    Holger
  3. Kendo UI is VS 2017 Ready
  4. PEIYANG
    PEIYANG avatar
    65 posts
    Member since:
    Jul 2012

    Posted 14 Apr 2013 Link to this post

    Thanks Holger  ,in the  grid I know how to read the grid:
     @(Html.Kendo().Grid(Model)
    .Name("Grid")
    .Columns(columns =>
    {
     columns.Bound(p => p.ProductName);
     })
     .Filterable()
    .DataSource(dataSource => dataSource
    .Ajax()
    .Read(read => read.Action("Products_Read", "Grid"))
    )
    )
    But as the way you said,I don't know how to  write them in JS? I have give the datasource as Model and autoBind=false in the grid,  Can you give me a example,I write below,It seems wrong.

    dataSource.read(("Products_Read", "Grid"))); //action ,control

  5. Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 14 Apr 2013 Link to this post

    Hi,

    Since I'm not using the ASP.NET MVC wrappers I have no knowledge about these. But after a look into the documention it seems the AutoBind configuration is also available in the wrapper.

    I don't know how to access the grid's datasource in the MVC wrapper, but in JavaScript you will do it like this:
    var grid = $('#grid').data('kendoGrid');
    grid.dataSource.read();
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 15 Apr 2013 Link to this post

    Hello PEIYANG,

     
    Indeed there is a AutoBind setting in MVC wrappers/as linked in Holger's post/ and it will prevent initial ajax call to the server.

    In order to obtain reference to Grid client object you must use the id defined in the Name configuration setting:

    @(Html.Kendo().Grid(Model)
    .Name("Grid")
    .....
     
    //reference to above **Grid**
    var grid = $("#Grid").data("kendoGrid");
    grid.dataSource.read();

    You can find more details in Grid MVC wrapper overview topic.
    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready