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

dynamic schema data in grid

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gerd
Top achievements
Rank 1
Gerd asked on 24 Apr 2012, 02:19 PM
Is there a possibility to aggregate the grid schema dat aon the fly with ajax? I tested ist with a function but it didn't work.
i.e.:
It seems not to work cause if the data format, i guess ... any idea?

in the grid object:
schema: getSchema()


the function:
function getSchema()
{
var dataReturn;
    $.ajax({
        url: "/ajax/listen/getschema",
        success: function(data){
            console.log(data);
            dataReturn = eval( "("+ data +")");
        },
        error: function(data){
            console.log(data.responseText);
        },
        complete: function(jqXHR, textStatus){
            console.log(jqXHR);
            console.log(textStatus);
        }
    });
    return dataReturn;
}

1 Answer, 1 is accepted

Sort by
0
GungFooMon
Top achievements
Rank 1
answered on 25 Apr 2012, 08:59 AM
You are trying to return data from an asynchronous call, which can by definition not work because your getSchema() function will return before success is called, therefore always yielding an empty return value.
You could try setting "async: false" in the ajax object and have the success function set a global variable that can then be returned.
Tags
Grid
Asked by
Gerd
Top achievements
Rank 1
Answers by
GungFooMon
Top achievements
Rank 1
Share this question
or