Configure Grid datasource to call Javascript function

2 posts, 1 answers
  1. Patrick
    Patrick avatar
    4 posts
    Member since:
    Mar 2015

    Posted 30 Dec 2015 Link to this post


     We use a framework that wrap every ajax response. Instead to have this :

    AggregateResults: null
    Data: [{Name: "name1", Title: "M.",},…]
    Errors: null
    Total: 4

     the response from controller method are :

    error: null
    result: {data: [{name: "name1", tile: "M."},…], total: 4,…}
    success: true
    unAuthorizedRequest: false


    I would like to use a javascript function so that  can manipulate the ajax response and extract the data before passing it to the Grid.

    Is there a way to achieve that? Thank you.

  2. Answer
    Rosen avatar
    3253 posts

    Posted 04 Jan 2016 Link to this post

    Hello Patrick,

    When using ASP.NET MVC wrapper, this can be achieve via setting Custom DataSource configuration. This will allow you to set a custom function for the schema.parse and return the appropriate portion of the response. For example:

        .DataSource(dataSource => dataSource
            .Transport(transport =>
                transport.Read(read => read.Action("Read", "Grid"))
            .Schema(schema => schema.Parse(@<text>
                function(response) {
                    return response.result;

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top