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

7 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
    78 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. 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

  4. Holger
    Holger avatar
    78 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();
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2287 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!
  6. Stewart
    Stewart avatar
    1 posts
    Member since:
    Jan 2016

    Posted 15 Dec 2016 Link to this post

    I have a similar situation but slightly different:

    I have a datasource that loads a list of items for a dropdownlist.  I then have a dropdownlist that is constructed on the fly in an editor function for a grid column.  Each time I activate the editor, the datasource makes an ajax request to the server to load the data for the dropdownlist.  I tried adding the autoBind=false attribute to the editor (see code below) but it STILL makes an ajax call to the server to reload the data for the dropdownlist.  I want to be able to load the data source once and not have it reload on each activation of the editor but the autoBind does not seem to work in my case.

    $('<input data-text-field="displayfield" data-value-field="valuefield" data-bind="value:' + options.field + '"/>')
        .appendTo(container)
        .kendoDropDownList({
            dataSource: dsLookupCompany,
            autoBind: false
        });

    --Stewart McGuire

  7. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2287 posts

    Posted 19 Dec 2016 Link to this post

    Hello Stewart,

    This thread is 3 years old and seem like it is not directly related to your question. Please consider opening a new one thread with your issue described. Providing an isolated runnable example will also helps us assist you.

    Regards,
    Nikolay Rusev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top