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

datasource object not ready in ajax OnSuccess call?

1 Answer 83 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 17 Sep 2012, 08:53 AM
Hi,

I met a strange issue.

In DOM load, I create a kendo grid with remote data source:
$(document).ready(function () {
    LocationGridDataSource = new kendo.data.DataSource({ type: "json" ...);
    LocationGrid = ...
}

There is an ajax form in my page:
@using (Ajax.BeginForm("Bind", "Test", null, new AjaxOptions { OnSuccess = "BindOnSuccess" }, new { id = "BindForm" }))
{}

I use $("#BindForm").submit() to mannually submit the ajax form.
In BindOnSuccess, I use datasource.get:
function BindOnSuccess(context){
    ....
    var location = LocationGridDataSource.get(context.id);
    var selection = LocationGrid.table.find('tr[data-uid="' + location.uid + '"]');
    ....
}

Sometimes location which is got from LocationGridDataSource.get(context.id) is NULL, sometimes it will get object successfully.

After my debugging, my questions:
1. The problem is caused by LocationGridDataSource is not ready after ajax returns?
2. Is there a mechanism to ensure I can call LocationGridDataSource.get() based on a READY datasource object?

Any comments or instruction?

Thanks.

1 Answer, 1 is accepted

Sort by
0
John
Top achievements
Rank 1
answered on 27 Sep 2012, 03:33 PM
anyone knows this?
Tags
Data Source
Asked by
John
Top achievements
Rank 1
Answers by
John
Top achievements
Rank 1
Share this question
or