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

4 Answers 6091 Views
Grid
PEIYANG
Top achievements
Rank 1
PEIYANG asked on 13 Apr 2013, 04:20 AM
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
Stewart
Top achievements
Rank 1
commented on 16 Dec 2016, 02:13 AM

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

4 Answers, 1 is accepted

Sort by
0
Holger
Top achievements
Rank 1
answered on 13 Apr 2013, 04:50 PM
Hi,

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

Regards,
Holger
PEIYANG
Top achievements
Rank 1
commented on 14 Apr 2013, 06:18 AM

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

0
Holger
Top achievements
Rank 1
answered on 14 Apr 2013, 04:53 PM
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();
0
Nikolay Rusev
Telerik team
answered on 15 Apr 2013, 07:44 AM
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!
0
Nikolay Rusev
Telerik team
answered on 19 Dec 2016, 02:53 PM

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.
Tags
Grid
Asked by
PEIYANG
Top achievements
Rank 1
Answers by
Holger
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or