datasource object not ready in ajax OnSuccess call?

2 posts, 0 answers
  1. John
    John avatar
    15 posts
    Member since:
    Jul 2011

    Posted 17 Sep 2012 Link to this post

    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.
  2. John
    John avatar
    15 posts
    Member since:
    Jul 2011

    Posted 27 Sep 2012 Link to this post

    anyone knows this?
Back to Top