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

.data only runs once

2 Answers 74 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 03 Feb 2017, 04:10 PM
@(Html.Kendo().Grid<MyModel>()
        .DataSource(ds => ds
            .Custom()
            .Batch(false)
            .Schema(schema => schema.Parse(@<text>parseData</text>))
            .Transport(r => r.Read(c => c.Action("GetStuff", "MyController",
                new
                {
                     prop = Model.prop
                })
                .Data("getExtraData()").Type(HttpVerbs.Post)))
            .PageSize(1)
            .ServerPaging(true)
        )

 

The getExtraData() method runs the first time the grid is loaded. I want to refresh the grid later, so I use this c

$('#messagesgrid').data('kendoGrid').dataSource.read();
$('#messagesgrid').data('kendoGrid').refresh();

 

The method getExtraData() has changed, so when it refreshes I want it to call this method again to attach the data to my request. However the method does not run even though the grid is refreshed.

 

How can I make sure that it runs every time the grid is updated?

2 Answers, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 03 Feb 2017, 04:29 PM

I've fixed this by removing the brackets on the Data property.

 

.Data('someMethod') works

.Data('someMethod()') runs once then never runs again

0
Viktor Tachev
Telerik team
answered on 07 Feb 2017, 01:17 PM
Hi Phil,

Thank you for sharing with the community how you were able to resolve the error. Note that when you type a JavaScript method with brackets this will invoke the method immediately. Please examine the thread below that describes the behavior in more detail.


If you need additional information on sending data to the ActionMethods you would find the following article interesting.


Regards,
Viktor Tachev
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
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or